Snippet one:
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
function say(text) { | |
alert(text); | |
} | |
(function() { | |
var foo = "bar"; | |
})(); |
Snippet two:
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
var say = function(text) { | |
alert(text); | |
} | |
(function() { | |
var foo = "bar"; | |
})(); |
Surprising behavior. I'd be interested to find out if different browsers / JavaScript engines treat these code snippets in the same way.