I have a doubt regarding the use of
Apart from the obvious (the first one cannot be used if you don’t have a
this pointing to a suitable target, the second one will return
'' if the current active item in the workspace is not an editor), is there any reason why to choose one over the other when both may work?
For example, in the following code both options can be used:
atom.commands.add 'atom-text-editor', 'new-command', -> editor_thru_getModel = @getModel() editor_thru_getActiveTextEditor = atom.workspace.getActiveTextEditor() if editor_thru_getModel == editor_thru_getActiveTextEditor console.log "They're the same!"
The code above outputs
They're the same!, as expected. So, why using one or the other in such contexts? Is there any risk of
this being shadowed there?
Thanks a lot in advance and my excuses for the weird question. I’m new to Atom, Coffeescript, etc.