-
-
Save padolsey/1394591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
el.addEventListener('click', function openDialog(event) { | |
// open the dialog | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
el.addEventListener 'click', openDialog = (event) -> | |
# open the dialog | |
# no thanks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// what the coffeescript becomes | |
var openDialog; | |
el.addEventListener('click', openDialog = function(event) { | |
// open the dialog | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// what the coffeescript COULD become | |
// Using solution described here: http://kangax.github.com/nfe/#jscript-memory-management | |
// If the intention is to have a named-func-expression (just for debugging, not referenc'able by name): | |
el.addEventListener('click', | |
(function(){ | |
var openDialog, f = function openDialog(event) { | |
// open the dialog | |
}; | |
openDialog = null; // null so that openDialog does not reference extraneous func | |
return f; | |
}()) | |
); | |
// If the intention is to have the same BUT referenc'able by name: | |
var openDialog; | |
el.addEventListener('click', | |
openDialog = (function(){ | |
var openDialog, f = function openDialog(event) { | |
// open the dialog | |
}; | |
openDialog = null; // null so that openDialog does not reference extraneous func | |
return f; | |
}()) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment