JavaScript 中的"not in"运算符是否用于检查对象属性?
javascriptobject oriented programmingfront end technology更新于 2024/6/26 0:12:17
若要仅获取 else 部分,只需使用 JavaScript 中的 ! 运算符进行取反即可。您可以尝试运行以下代码来实现此目的 −
var arr = {};
if (!(id in arr)) {
}
else {
}
此外,如果您想知道对象中是否存在某个属性,请使用 hasOwnProperty −
if (!arr.hasOwnProperty(id)) {
}
else {
}
相关文章
有用资源
javascript 参考教程 - 该教程包含有关 javascript 的更多信息:https://www.cainiaomax.com/javascript/

