diff --git a/documentation/examples/objects_shorthand.coffee b/documentation/examples/objects_shorthand.coffee new file mode 100644 index 00000000..4d3a9e25 --- /dev/null +++ b/documentation/examples/objects_shorthand.coffee @@ -0,0 +1,5 @@ +name = "Michelangelo" +mask = "orange" +weapon = "nunchuks" +turtle = {name, mask, weapon} +output = "#{turtle.name} wears an #{turtle.mask} mask. Watch out for his #{turtle.weapon}!" diff --git a/documentation/index.html.js b/documentation/index.html.js index 495201c2..75bf60c9 100644 --- a/documentation/index.html.js +++ b/documentation/index.html.js @@ -457,6 +457,11 @@ Block about it (say, when using jQuery).

<%= codeFor('objects_reserved') %> +

+ CoffeeScript has a shortcut for creating objects when you want the key + to be set with a variable of the same name. +

+ <%= codeFor('objects_shorthand') %>