Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Length of a JavaScript object

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
const myObj = {}
var size = Object.size(myObj);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Length #JavaScript #object
ADD COMMENT
Topic
Name
6+5 =