gpt4 book ai didi

javascript - 查找对象中键的数量

转载 作者:行者123 更新时间:2023-12-03 02:33:26 24 4
gpt4 key购买 nike

Possible Duplicate:
How to efficiently count the number of keys/properties of an object in JavaScript?

var values = [{
'SPO2': 222.00000,
'VitalGroupID': 1152,
'Temperature': 36.6666666666667,
'DateTimeTaken': '/Date(1301494335000-0400)/',
'UserID': 1,
'Height': 182.88,
'UserName': null,
'BloodPressureDiastolic': 80,
'Weight': 100909.090909091,
'TemperatureMethod': 'Oral',
'Resprate': null,
'HeartRate': 111,
'BloodPressurePosition': 'Standing',
'VitalSite': 'Popliteal',
'VitalID': 1135,
'Laterality': 'Right',
'HeartRateRegularity': 'Regular',
'HeadCircumference': '',
'BloodPressureSystolic': 120,
'CuffSize': 'XL'
}];

for (i=0; i < values.length; i++) {
alert(values.length) // gives me 2.

如何找到我的对象有多少个键?

最佳答案

var value = {
'SPO2': 222.00000,
'VitalGroupID': 1152,
'Temperature': 36.6666666666667,
'DateTimeTaken': '/Date(1301494335000-0400)/',
'UserID': 1,
'Height': 182.88,
'UserName': null,
'BloodPressureDiastolic': 80,
'Weight': 100909.090909091,
'TemperatureMethod': 'Oral',
'Resprate': null,
'HeartRate': 111,
'BloodPressurePosition': 'Standing',
'VitalSite': 'Popliteal',
'VitalID': 1135,
'Laterality': 'Right',
'HeartRateRegularity': 'Regular',
'HeadCircumference': '',
'BloodPressureSystolic': 120,
'CuffSize': 'XL'
};

alert(Object.keys(value).length);

关于javascript - 查找对象中键的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6723610/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com