javascript object property lookup

后端 未结 3 890
孤街浪徒
孤街浪徒 2021-01-16 05:10

Due to object in javascript is associative map (HashMap in other programming languages) does next code

for (var prop in object) {
    if (prop === someConc         


        
3条回答
  •  爱一瞬间的悲伤
    2021-01-16 05:28

    This can be tested empirically:

    
    

    Method 1 takes MUCH longer than Method 2. This is hardly surprising since all of the computing necessary to execute Method 2 is included in Method 1 plus MUCH more.

提交回复
热议问题