I wrote this code on my website
for(var i = 0; i < 10; i++){
console.log([] > []);
}
and got this output
LOG: false
LOG: true
LOG: true
LOG: false
LOG: false
LOG: false
LOG: true
LOG: false
LOG: true
LOG: false
The output changes every time I run it. Why is this strange behavior happening?
You can try it out for yourself on this jsFiddle demo.
In the jsFiddle,
Array.prototype.toStringhas been overridden with the following…Try it like this…