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?
It is white space. For example you have a container with 100% of width and two divs inside, one of those with 50% and another width 40% of width, it means that there is 10% of space empty... this 10% would be shown in this purple dashed line area by the Google inspector.
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++
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With