Created
September 13, 2018 16:08
-
-
Save rafagarcia/cc959d9588691b21811ad997a5d14e56 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/kakazog
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
| // spread operator examples | |
| let a = [3, 4, 5]; | |
| let b = [1, 2, ...a, 6]; | |
| console.log(b); | |
| function foo(a, b, c) { console.log(`a=${a}, b=${b}, c=${c}`)} | |
| let data = [5, 15, 2]; | |
| foo( ...data); | |
| let car = { type: 'vehicle ', wheels: 4}; | |
| let fordGt = { make: 'Ford', ...car, model: 'GT'}; | |
| console.log(fordGt); | |
| a = [1, 2, 3]; | |
| b = [ ...a ]; | |
| c = a; | |
| b.push(4); | |
| console.log(a); // [1, 2, 3] | |
| console.log(b); // [1, 2, 3, 4] referencing different arrays | |
| c.push(5); | |
| console.log(a); // [1, 2, 3, 5] | |
| console.log(c); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment