js/jsfun/fnObject.js 对象操作
let obj = {"zzz": "ZZZZ", "aa": "AAAA", "title": "TITLE"}
if (obj["bb"] == undefined) {
console.log("bb is undefinded")
} else {
console.log("bb is not undefinded")
}
//这边bb已经声明,所以可以直接与undefined对比判断
let bb = obj["bb"]
if (bb == undefined) {
console.log("bb2 is undefinded")
} else {
console.log("bb2 is not undefinded")
}
//这边的cc未声明,无法确定cc是否之前已经声明,无法直接用==undefined对比判断,需要通过判断类型才能确定cc是否已经声明。
// cc的类型值
console.log("cc is:", typeof cc)
// cc的类型值的类型
console.log("cc is:", typeof typeof cc)
if (typeof cc == "undefined") {
console.log("cc is undefinded")
} else {
console.log("cc is not undefinded")
}
//取得对象的第一个属性值
console.log("对象的第一个属性值:", fnObject_current(obj))
console.log("对象是否为空:", fnObject_isNotNull(obj));
console.log("对象是否为空:", fnObject_isNotNull(obj["dd"]));