Last active
August 29, 2015 13:57
-
-
Save timaschew/9519475 to your computer and use it in GitHub Desktop.
demo snippest of js2coffee talk at Berlin Node.js Meetup #3 - 2014-03-12 - try it out on http://js2coffee.org
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
// buggy when switch multiple times (js2coffee, coffee2js, js2coffee, ...) | |
foo = "bar" | |
// avoid the bug | |
main.foo = "bar"; | |
// example for variable shadowing | |
var x = 0; | |
main.f = function(err, res) { | |
var x = 1; | |
}; | |
// existence operator | |
if (main.foo != null) { | |
qux(); | |
} | |
// inversible operators | |
if (foo && bar !== true || anything()) { | |
qux(); | |
} else { | |
baz(); | |
} | |
// show later in the slides (ternary operator) how this would be converted with js2coffee | |
main.foo = boolVal ? "yes" : "no"; | |
// pretty print for complex object structures | |
main.x = { | |
foo: 1, | |
bar: 2, | |
nested: { | |
foo: 3, | |
bar: 4 | |
}, | |
array: [ | |
1, 2, { | |
foo: 1 | |
}, { | |
bar: 2 | |
} | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment