In JavaScript, arrays can be created with the Array constructor, or using the [] convenience shortcut, which is also the preferred approach. Arrays inherit from the Object prototype and they haven't a special value for typeof, they return'object' too. Using [] instanceof Array, however, returns true. That being said, there are also Array-like objects which complicate matters, such as strings, or the arguments object. The arguments object is not an instance of Array, but it still has a length property, and its values are indexed, so it can be looped like any Array.
In this article I'll go over a few of the methods on the Array prototype, and explore the possibilities each of these methods unveil.
Your new post is loading...