Skip to content

Instantly share code, notes, and snippets.

@rafagarcia
Created September 13, 2018 16:08
Show Gist options
  • Select an option

  • Save rafagarcia/cc959d9588691b21811ad997a5d14e56 to your computer and use it in GitHub Desktop.

Select an option

Save rafagarcia/cc959d9588691b21811ad997a5d14e56 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/kakazog
// 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