📜  JavaScript 对象的长度 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:59.730000             🧑  作者: Mango

代码示例4
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);