웹 개발

javascript object size

노루아부지 2019. 8. 17. 00:26
Object.size = function(obj) {
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) size++;
    }
    return size;
};

// Get the size of an object
var size = Object.size(myArray);

출처 : http://stackoverflow.com/questions/5223/length-of-javascript-object-ie-associative-array

728x90
loading