<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var cars = ["BMW", "Volvo", "Saab", "Ford"];
var i = 0;
var text = "";
for (;cars[i];) {
text += cars[i] + "<br>";
i++;
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
The tricky thing is here:
for (;cars[i];) {
text += cars[i] + "<br>";
i++;
}
From: tryjs_loop_for_cars in w3schools
Isn't the statement 2 of For-loop used to be evaluated and terminate the loop if it's false? Isn't statement 2 of Boolean type? How could it be used like a For/In loop?
I need help, who knows the legacy of this or the things behind this? Is this supposed to be a backdoor feature?
I have eyes, I know this exists now, don't tell me this just exists, but how it works?