Skip to content

Instantly share code, notes, and snippets.

@paultag
Created January 24, 2013 14:30
Show Gist options
  • Save paultag/4622311 to your computer and use it in GitHub Desktop.
Save paultag/4622311 to your computer and use it in GitHub Desktop.
ECMAScript 6 spread operator
/* See:
http://bit.ly/WhXvb3
for the Traceur */
var foo = [9, 9, 9],
bar = [2, 2, 2],
baz = [1, 1, ...foo, 1, 1, ...bar, 1, 1];
console.log(baz);
/* Output: 1,1,9,9,9,1,1,2,2,2,1,1 */
/* This is similar to Clojure's
unquote-expand operator:
(let [foo [9 9 9]
bar [2 2 2]
baz `[1 1 ~@foo 1 1 ~@bar 1 1]]
(println baz))
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment