Below examples implement the above concept:
Example 1: This example demonstrates array.size() method and array.length property.
Length of the array is: 3 error on console: TypeError: arr.size is not a function
Note: The array.length property returns value of last_key+1 for Arrays with numeric index value. This property doesn’t guarantee to find the number of items in the array.
Example 2: This example display how Array.length property works.
Length of the array is: 51
Example 3: This example display how array.length property works when index key is non numeric.
Length of the array is: 0
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : karthi03