Chrome DevTools: what's this arrow(<-) meaning?

我与影子孤独终老i 提交于 2019-12-10 19:47:08

问题


I am confuse about this symbol (<-) in Chrome DevTools

It's return value or console value?

When I run this while loop

var i = 0;
while (i < 5) {
    console.log(i);
    i++;
}

the console log spits out 4 twice, the last 4 have a (<-) in a front, what's meaning?


回答1:


This has to do with the nature of the eval function. Note that:

var i = 0, j = while(i < 5) { i++; };

Produces a compile error. However,

var i = 0, j = eval('while(i < 5) { i++; }');

Assigns the value 4 to j. Why is this? Quoting from MDN:

eval() returns the value of the last expression evaluated.

So in short, it evaluates all the calls to console.log in your expression, then also logs the return value from the eval-ed expression itself, which just happens to be the result of the last i++.



来源:https://stackoverflow.com/questions/21820746/chrome-devtools-whats-this-arrow-meaning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!