Q:

Get concat to work with an array-like object

There are places I change an array to an array like object like so:
let arr = ['a','b']
let arrLike = {...arr, length: arr.length}
console.log(arrLike)
> {0: "a", 1: "b", length: 2}

It's not perfect, but this allows me to override arrays by using a merge. ie:
> let a1 = [1,2,3], b1 = [1,2,3]
> Object.assign(a1, arr)
[ 'a', 'b', 3 ]
> Object.assign(b1, arrLike)
[ 'a', 'b']

which is desirable but I would also like concat to work, 
['z'].concat(arr)
> ["z", "a", "b"] // good
['z'].concat(arrLike)
> ["z", {0: "a", 1: "b" length: 2}] // bad

Is there anyway to modify arrLike such that concat would work?

A:

You need to define Symbol.isConcatSpreadable to tell concat() to treat it as array-like:
arrLike[Symbol.isConcatSpreadable] = true;

Example:

let arr = ['a','b'];
let arrLike = {
  ...arr, 
  length: arr.length,
  [Symbol.isConcatSpreadable]: true
};

console.log(['z'].concat(arrLike))

