![]() |
VOOZH | about |
The JavaScript array length property returns or sets the number of slots in an array. It is often the same as the number of elements, but arrays can contain empty slots, making the two values different.
The length property can also be used to set the length of an array. It allows you to truncate or extend the array.
Setting the length property to a smaller value removes elements from the end of the array.
Setting the length property to a larger value increases the array size by adding empty slots at the end.
String Length properly works same way, but we cannot modify length of a string as strings are immutable.