Spread operator

Spreads an array into its individual values.

  1. var a = [1, 2];
  2. var b = returnTwo(a[0], a[1]); // [2, 1]
  3. var c = returnTwo(...a); // [2, 1]

concat arrays with spread

  1. let nums = [1, 2, 3];
  2. let abcs = ['a', 'b', 'c'];
  3. let alphanum = [ ...nums, ...abs ]; // [1, 2, 3, 'a', 'b', 'c']

Object.assign shorthand

  1. const o = {num: 0, txt: 'hi'};
  2. const newO = {...o, num: 1};