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

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs