//reset value of dict b if there is a key as it is in dict a //javascript var a = {} var b = {} //... a got some values, b got some values for (var k in a) { if (b[k]) { b[k]=a[k] } }
【在 h**********c 的大作中提到】 : //reset value of dict b if there is a key as it is in dict a : //javascript : var a = {} : var b = {} : //... a got some values, b got some values : for (var k in a) { : if (b[k]) { : b[k]=a[k] : } : }
K in a 说明k是a的element 那循环体里面a[k]是什么鬼? Sequence 的元素,做sequence的running index?
r*d
9 楼
打YiSu三十大板
a9
10 楼
if(b[k])可能不对如果b[k]==0就不会reset了
【在 h**********c 的大作中提到】 : //reset value of dict b if there is a key as it is in dict a : //javascript : var a = {} : var b = {} : //... a got some values, b got some values : for (var k in a) { : if (b[k]) { : b[k]=a[k] : } : }
Y*u
11 楼
看清再打啊。。。冤板。。
【在 r*****d 的大作中提到】 : 打YiSu三十大板
h*c
12 楼
Awesome, case resolved. but preferrable i guess should be ===