Array.prototype.lengthbeginnerconst arr = [10, 20, 30]
arr.length // β 3Read the length property to get the number of elements in an array.
Array.prototype.length is a property (not a method) that returns the number of elements in an array. It is always a non-negative integer and updates automatically as elements are added or removed.
Challenge: Implement getLength(arr) that returns the length of the array.
getLength([1, 2, 3]) // β 3
getLength([]) // β 0