Javascript performance consideration. Is dot operator faster than subscript notation?

后端 未结 2 972
挽巷
挽巷 2020-12-06 13:02

Is dot operator faster than subscript notation?

var obj = {x: \'5\'};
obj.x = \'some value\';
obj[\'x\'] = \'some value\';
2条回答
  •  再見小時候
    2020-12-06 13:23

    Not anything incredibly worrying. Acessing variables by window or eval are significantly slower though.

    http://jsperf.com/dot-vs-square-bracket/5

提交回复
热议问题