JS遍历对象中的所有属性并获取属性值
2020-07-14 本文已影响0人
瑟闻风倾
- 对象 cs_num
{"cs_num2[2_2]":"","cs_num1[1_1]":"","cs_num0[1_1]":"","cs_num0[0_0]":"","cs_num2[0_0]":"","cs_num1[2_2]":"","cs_num2[1_1]":"","cs_num1[0_0]":"","cs_num0[2_2]":""}
- 遍历对象中的所有属性并获取属性值
commit:function(cs_num){
var count = 0
for (let item in cs_num) {//遍历属性
if(cs_num[item] != ""){//获取属性值
count += 1
}
}
console.log("commitStorageInfo:" + count)
if(count == 0){
return
}
}