js 中遍历对象属性的方法。
一般 . 操作就可以,但是自己写的时候发现只能用 [] 来获取。
const log = console.log.bind(console)
let a = {
ab: '11',
ac: '22',
cc: undefined,
dd: null,
bc: '33'
}
for (var i in a) {
log(a[i])
log(a.i) //这一个输出都是undefined
}
///
> "11"
> "22"
> undefined
> null
> "33"
> 扩展问题: 点获取对象属性和 方括号的区别?
[搜别人的文章](https://blog.youkuaiyun.com/sinat_36359516/article/details/109987859)