Valid array indexes are integers or strings “look” like integers. Only valid array indexes get counted in the length of an array, so since “baz” is not a valid array index, it does not increase the length.
Because “3” looks like 3, it will be considered a valid array index and change the length of the array.
No, it is highly recommended to use proper array methods such as push and unshift for adding elements to an array. Using a built-in method guarantees properties like length have the correct value. For example, let’s say you have: