소스코드
var h = {};
console.log(typeof h);
h['a'] = 'aa';
h['b'] = 'bb';
Object.prototype.testFunction = function() {
console.log('testFunction called');
}
console.log('length property = ' + h.length);
for (var i in h) {
console.log(i + ' > ' + h[i]);
}
console.log(Object.keys(h));
결과
[test.html:4] object
[test.html:12] length property = undefined
[test.html:14] a > aa
[test.html:14] b > bb
[test.html:14] testFunction > function () {
console.log('testFunction called');
}
[test.html:17] Array[2]
0: "a",
1: "b",
length: 2,
__proto__: Array[0]