Javascript性能考虑。点运算符比下标表示法更快吗? [英] Javascript performance consideration. Is dot operator faster than subscript notation?
本文介绍了Javascript性能考虑。点运算符比下标表示法更快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
点运算符是否比下标表示法快?
Is dot operator faster than subscript notation?
var obj = {x: '5'};
obj.x = 'some value';
obj['x'] = 'some value';
推荐答案
没有什么令人难以置信的担忧。按窗口
或 eval
访问变量的速度要慢得多。
Not anything incredibly worrying. Acessing variables by window
or eval
are significantly slower though.
http://jsperf.com/dot-vs-square-bracket/5
这篇关于Javascript性能考虑。点运算符比下标表示法更快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文