var person = { [Symbol('nameJohn Doe', [Symbol('age')]: 33, "occupation": "rogrammer"};const propOwn = Object.getOwnPropertyNames(person);console.log(propOwn.length); // 1let propSymb = Object.getOwnPropertySymbols(person);console.log(propSymb.length); /code]较旧的答案最可靠的答案是:[code]Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size ; } return size;};// Get the size of an objectconst myObj = {}var size = Object.size(myObj);( n& |) q5 W. I( l5 X* H