JavaScript performance optimization - call methods or attributes of array elements

From , 5 Years ago, written in JavaScript, viewed 91 times.
URL https://pastebin.vip/view/b8dd669b
  1. //直接使用数组元素调用,慢
  2. myArray[myIndex].myMethod1();
  3. myArray[myIndex].myMethod2();
  4. myArray[myIndex].my_variable;
  5.  
  6. //放到变量里再通过变量调用,快
  7. var element = myArray[myIndex];
  8. element.myMethod1();
  9. element.myMethod2();
  10. element.my_variable;
  11. //javascript/2145

Reply to "JavaScript performance optimization - call methods or attributes of array elements"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website