Can anyone explain why the second warning says?
var pollData = new array); PollData ['pollType'] = 2; Alert (pollData ['pollType']); // It prints 2 warnings (pollData.length); // print it 0 ?? The length of the array changes when you add a numerical index. For example,
pollData ["randomString"] = 23; has no effect on the length, but
var pollData = []; PollData ["45"] = "Hello"; PollData.length; // 46 Change length to 46 Note that if there was a number or string, then it does not matter unless it is a numerical integer.
Besides, you do not want to use the array in this way. Think more about this one side effect, because the arrays are also objects, and any object in javascript can put an arbitrary key in the form of strings.
Comments
Post a Comment