Could someone possibly take a look at this:
http://jsfiddle.net/VkFRU/4/
and explain the console output I’m seeing (which is “0”, “true”, “false” and “덜 읽기”)?
The four individual console.log() calls output exactly what I expect, except for the the first one. Why is it saying length is 0?
The one in the $.each() iterator doesn’t output anything. Why not?
Only numerical properties are taken into account for
length.'ko'is not numerical.From the specification:
Where array index is defined as:
Therefore
kois not an array index.Because jQuery recognizes the arguments as array an iterates over its values, probably in this way:
You already noticed that
translations.lengthis0.You are making the mistake to use an array as associative array. Use an object instead:
The reason why you can assign non-numerical properties to arrays is simply the fact that arrays are objects too. But that does not mean that you should use them as such. The special array methods don’t apply to non-numerical properties.
I’d suggest you read more about arrays in the MDN JavaScript Guide.