array.length
8th February 2021
0 Comments
Programming Language
JavaScript [Version: ECMAScript (ECMA-262)]
Syntax
Typical Usage
Getting the number of items in an array in JavaScript.
Return Value(s)
Returns the array length as an integer.Notes
You cannot assign values to arr.length. For example, arr.length = 9 has no effect.
Examples of array.length
Example 1
var cars = ['focus', 'fiesta', 'kuga', 'mustang'];;
console.log(cars.length);
The above will log 4 to the console because there are four items in the array.
Similar Functions in Other Languages
- PHP: count()
Was This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.