As someone diving into the world of javascript and currently unpacking destructuring, I stumbled upon a puzzling snippet that sparked a question in my mind. After some editing, my code was identified as an array by the console, which left me scratching my head.
1: Why is this not recognized as an array?
const heroes = [{
lol: ['l', 'Iron Man']
}]
const [lol, dc] = heroes;
console.log(Array.isArray(lol));
2: On the contrary, why is this one flagged as an array?
const heroes = {
lol: ['l', 'Iron Man']
}
const {lol, dc} = heroes;
console.log(Array.isArray(lol));