
|  |      1aveline      2013-11-24 16:12:48 +08:00  1 用 friends[i]。 | 
|  |      2clippit      2013-11-24 16:13:21 +08:00  1 friends[i] | 
|  |      4housne      2013-11-24 16:22:40 +08:00  1 . 只能访问到关键字,很明显这里的 i 是变量,要用 [] | 
|  |      6dorentus      2013-11-24 17:17:20 +08:00  1 >> for(var i in friends) >> 第一次循环时,i 的值是字符串 'bill' >> friends.i 等价于 friends['i'] >> 而你想要的是 friends.bill,等价于 friends['bill'] | 
|  |      7mopig OP @dorentus friends.bill, friends['bill'] 这个是等价的吧,只是在加载 i 的时候变成了:friends.'bill' ? | 
|  |      8bombless      2013-11-24 21:52:53 +08:00  2 噗……楼主还是没习惯。 a.i 就是 a['i'] 那你想,你要得到 friends.bill 那就应该是 friends['bill'] ,想得到 friends.i 就是 friends['i'] 你写的是 friends.i ,等价于 friends['i'] ,它显然和 friends['bill'] 不是同一个东西。 完全不存在friends.'bill'这种东西。 这里也不存在“加载i的时候”怎么样了,因为 friends.i 永远都是 friends['i'] 不可能变成 friends['bill'] | 
|      10xiezi      2013-11-25 22:01:29 +08:00 这个应该的错误信息是"Cannot read property 'firstName' of undefined",这说明friends.i是没有定义的,而不是你写的“firstName undefined”。@bombless写的很清楚了! |