Last active
August 29, 2015 14:22
-
-
Save davelnewton/11c622f7b11351eb2b11 to your computer and use it in GitHub Desktop.
CoffeeScript IIFEs
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
For the blog post at: | |
http://buckybits.blogspot.com/2015/06/coffeescript-iifes.html |
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 () { | |
var nonGlobalVar = "foo"; | |
var alsoNonGlobal = "bar" | |
console.log(nonGlobalVar + " " + alsoNonGlobal); | |
})(); |
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
(-> | |
nonGlobalVar = "foo" | |
alsoNonGlobal = "bar" | |
console.log "#{nonGlobalVar} #{alsoNonGlobal}")() |
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
do -> | |
nonGlobalVar = "foo" | |
alsoNonGlobal = "bar" | |
console.log "#{nonGlobalVar} #{alsoNonGlobal}" |
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
((s) -> | |
nonGlobalVar = "foo" | |
alsoNonGlobal = "bar" | |
console.log "#{nonGlobalVar} #{alsoNonGlobal} #{s}" | |
)("baz") |
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
do (s = "baz") -> | |
nonGlobalVar = "foo" | |
alsoNonGlobal = "bar" | |
console.log "#{nonGlobalVar} #{alsoNonGlobal} #{s}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment