In
JavaScript, an object treats each key as a string whether it's a number value,
boolean value or any other primitive value.
HelloWorld.js
var obj = {"id" : 123, 1 : "2", 2 : "3", 3 : "5", true : true}; for(var key in obj){ console.log(key + " : " + typeof key) }
Output
1
: string
2
: string
3
: string
id
: string
true : string
true : string
No comments:
Post a Comment