2013-07-09

JavaScript Object's Properties Are Strings

remember, in JavaScript, Objects are just unordered key/value pairs. And the keys are string, cannot be numbers. (the value can be any type) If you have o = {2:7, 3:4}, the keys are still strings, because JavaScript automatically does number to string conversion.

here's a example.

o = {"a":7, 2:4}
var k = Object.keys(o);

console.log(typeof(k[0]))       // string
console.log(typeof(k[1]))       // string