Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

demo snippest of js2coffee talk at Berlin Node.js Meetup #3 - 2014-03-12 - try it out on http://js2coffee.org

View js2coffee.org.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
// 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
Something went wrong with that request. Please try again.