This is a simple for loop in javascript. It declares that the initial I value is 0 and determines whether I is less than 100. If yes, It executes the statement and then increases I by 1. Therefore, vari = 0 is executed only once, and the conditional expression I & lt; 100 is executed
Each byte of code has its temperature, and we provide a code thermometer.
Double-click the source code
123 |
For (vari = 0; I <100; I ++) {console. log (I );} |
This is a simple for loop in javascript. It declares that the initial I value is 0 and determines whether I is less than 100. If yes, It executes the statement and then increases I by 1. SoVar I = 0Execute only once, condition expressionI <1, 100Will Execute 101 times, incrementalI ++Executed 100 times,Console. log (I)Run 100 times.
Statement |
Times |
Var I = 0 |
1 |
I <1, 100 |
101 |
I ++ |
100 |
Console. log (I) |
100 |
The conversion statement code maps the number of executions. We get a heat map of code execution, which vividly shows the actual code execution, it indicates the execution heat of each statement. We say this is the actual temperature of every byte code.
The heat map generated by the Code in the following quick sorting is displayed, and the javascript code coverage is shown in the lower right corner:
- Link: http://madscript.com/jsprofiler
- Github Source: https://github.com/yuanyan/jsprofiler
Reprinted please indicate the original address: http://www.alloyteam.com/2012/06/javascript-the-profiler