Home > Web Front-end > JS Tutorial > body text

Efficiency testing of global variables, internal variables and constant expressions in JavaScript_javascript skills

WBOY
Release: 2016-05-16 18:41:34
Original
996 people have browsed it


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

Note: Do it in IE For this test, you need to first change IE's "Maximum number of script steps":
[HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerStyles]
"MaxScriptStatements"=dword:ffffffff
Looking at it this way, using local variables within a function is more efficient than using global Variable or constant expressions are much higher. The efficiency of attributes is terrible. In Firefox and Safari, it is many times slower than using global variables.
Using string constants directly is faster than using global variables, but creating regular expressions is much slower than using global variables. Looking at the numbers, we can also find that in Google Chrome, Opera and IE, there is not much difference between using attributes and using global variables (Opera’s performance may be caused by its garbage collection mechanism). From this phenomenon, these three The so-called global variables in a browser may simply be properties of the global object.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template