JavaScript性能优化

JavaScript性能优化

循环

  1. For 循环
1
2
3
for (var i = 0; i < 10; i++) {
// do something
}
  1. For/In 循环
1
2
3
4
5
// TODO 不推荐,相同的迭代次数,性能是其他三种的1/7
var person = { fname: "John", lname: "Doe", age: 25 };
for (x in person) {
txt = txt + person[x];
}
Read more