javascript object 관련 테스트javascript object 관련 테스트
Posted at 2014. 11. 10. 16:42 | Posted in 프로그래밍 언어/Javascript소스코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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]