HTML
<p>index++</p>
<div id="result1"></div>
<p>--index</p>
<div id="result2"></div>
js
var index1 = 0;
var index2 = 0;
var result1 = 0;
var result2 = 0;
for(var loop_index = 0;loop_index < 100;loop_index++)
{
result1 = index1++;
document.getElementById('result1').innerHTML = "loop_index : " + loop_index.toString() + " | index : " +(result1).toString();
}
for(var loop_index = 0;loop_index < 100;loop_index++)
{
result2 = ++index2;
document.getElementById('result2').innerHTML = "loop_index : " + loop_index.toString() + " | index : " +(result2).toString();
}
demo link : https://jsfiddle.net/yagdmirage/e1gkz7hc/
'js' 카테고리의 다른 글
[javascript] JSON datetime string to javascript date format yyyy-MM-dd hh:mm:ss (0) | 2018.02.28 |
---|---|
[javascript] 나누기, 나머지, 몫 구하기 (0) | 2018.02.22 |
[javascript] Uncaught TypeError: is not a function (0) | 2018.01.10 |
[jquery] how to get custom attribute value (0) | 2017.12.29 |
[javascript] get parameters to object (0) | 2017.12.28 |