0
JS array question
why c does not become part of the arr, yet when calling arr.key it exists? var arr = []; arr[0] = "x"; arr[1] = "y"; arr.key = "c"; alert(arr.length);
5 Answers
+ 2
Similarly, the array methods are also only applied to the elements with numeric indexes.
+ 2
the length property only applied to the elements with numeric indexes.
0
To add new element to a Array use 'push' method.
Code:
arr.push("c");
0
Hi Thomas. Thanks for your reply. However, rather than a solution, I am after being able to understand what's happening with c in this example.
0
thanks Calvin. and why when I call the arr it returns only x,y? (not c)