An object, {}, can look like an array, e.g.
const x = {}
x[0] = 1 // works
console.log(x[0]) // works
console.log(x.0) // doesn't work
const [first] = x // doesn't work, non-iterable object
For example, arrays are by default converted(auto-coercion allowed, means signal “==“ ) to strings by simply joining all the values with commas (,) between them. You might think that two arrays with the same content are equal ==, when in fact they are not:
var a = [1,2,3];
var b = [1,2,3];
var c = "1,2,3";
a == c; // true
b == c; // true
a == b; // false
Top comments (0)