I have been reading that in Javascript :
- Everything is an object (except primitives such as number,string, boolean, null & undefined)
- Objects can be treated as associative arrays.
From what I conclude, Array.isArray() should return true for everything (with primitive exceptions aforementioned). What wrong did I understand ?
Thanks !
There’s a difference between an Object and an Array. An Array is actually an Array Object. It has different methods than other objects. A String is a String object. However, you can access objects as if they were an array. Take the following object
You can get values like
This doesn’t mean that it’s an Array Object, it just has a different way of accessing it
isArray() checks if the object is an Array Object, not if you can access it like an array