
[英]How can I modify the properties of a promise to be equal to the properties of an object in AngularJS?
[英]How can I check if any of the values of the object properties are equal to 0?
如何检查对象属性的任何值是否等于0?
您将必须遍历对象键,并检查每个键的值 :
for(var p in x) {
if(x[p] === 0) {
console.log("Found!");
}
}
根据您是否关心可能已经从prototype
继承的属性,可以在其中添加hasOwnProperty
检查:
for(var p in x) {
if(x.hasOwnProperty(p)) {
if(x[p] === 0) {
//Found it!
}
}
}
我使用ActionScript编程,这是一种类似的方言,因此我几乎可以肯定它是相同的。 请试试:
if(arr[0] != null)
请注意, arr[0]
和arr["0"]
之间存在差异
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.