I've just picked up javaScript and i am amazed to see that javaScript arrays can hold any type of data in them, for example, a number and a string both can be stored in a single array. well, i've always studied in my Data Structures classes that "Array is a container which can hold fix number of items and these items should be of same type". My question is :- Is javascript a special case? or, they have changed the definition of array?
Quoting Mozilla JS Reference on this:
Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed.
More on this can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With