+ 9
Why the output is 2???
var arr = ["","",]; alert(arr.length) _______________________________________ There are two strings in the array but 1 number which is not in quotation marks. There are two commas it means three items can be added. David Carroll , bobbie
4 Answers
+ 5
Tahir Usman Trailing commas in arrays are ignored in Javascript.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas
+ 9
It is arr.length asking for the length not for indexđ§ Alex Tusinean đ„
+ 8
Thank you David Carroll
+ 2
đ§ Alex Tusinean đ„ not quite. See David Carroll 's answer.