Created
January 24, 2013 14:30
-
-
Save paultag/4622311 to your computer and use it in GitHub Desktop.
ECMAScript 6 spread operator
This file contains hidden or 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
/* 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