Chestnut:
var a = {'1':'gg','2':'love','4':'meimei',length:5};
var arr=[.. .a];
console.log(arr);
Error reported under Google Chrome: Uncaught TypeError: a[Symbol.iterator] is not a function
Definition of array-like:/a/11...
javascript introduction documentation on ‘...’: https://developer.mozilla.org...
The official JavaScript documentation says that '...' can convert a class array into an array. Why does it still report an error? confuse!
You should read the article you posted carefully first.
You cannot use the array method directly. Isn’t your extension statement used directly?
You need to convert the class array into an array first, you can use
introduced in the articleArray.prototype.slice.call(arguments)
ES6 also has a method,
Array.from(arrayLike)
Please use
Array.from()
If you look at the English page, you will find that the expanded object needs to be traversable
ES6 has so many new features, do you expect the browser to implement them all?