설명 :
Sample object:
var student = {
name : "홍길동",
sex : "남",
age : 24 };
코드 :
Object.objsize = function(Myobj) {
var osize = 0, key;
for (key in Myobj) {
if (Myobj.hasOwnProperty(key)) osize++;
}
return osize;
};
var student = {
name : "홍길동",
sex : "남",
age : 24 };
var objsize = Object.objsize(student);
alert('Size of the current object : '+objsize);
결과 :
Size of the current object : 3
등록된 댓글이 없습니다.