javascript object length

96

javascript object length -

var size = Object.keys(myObj).length;

can we find lenght of an object -

Object.keys(myArray).length

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);

Length of an object -

length(x)
length(x) <- value

Comments

Submit
0 Comments