I've discovered some very odd behavior from Array.from. It appears that it does not work as a callback function directly when mapped over an array of Array-like objects. I've tested in Chrome.
Here's some test code (ES6):
const fails = () => {
const x = {
0: 'help',
length: 1
};
const y = [x].map(Array.from); // will throw an Error
return y;
};
const works = () => {
const x = {
0: 'help',
length: 1
};
const y = [x].map(item => Array.from(item)); // will work
return y;
};
console.log(works());
console.log(fails());
https://jsfiddle.net/dox6wnya/
This is very peculiar behavior. I'm wondering why this happens.