var _tmp = 0;
for (var i = 0; sys.cores()[i]["sn"] != null; i++) { _tmp++; alert(_tmp); }
alert ("Pretty sure, you have " + _tmp + " virtual cores.");
This is the code that I'm working on. The loop itself is very simple. The output is: 1, 2, 3, 4. Just like expected, 4 virtual cores. But the alert()
after it, is not executed. Reason behind it is that:
os.cpus()[0]["model"] // TRUE, _tmp = 1;
os.cpus()[1]["model"] // TRUE, _tmp = 2;
os.cpus()[2]["model"] // TRUE, _tmp = 3;
os.cpus()[3]["model"] // TRUE, _tmp = 4;
os.cpus()[4]["model"] // FALSE/NULL -> ERROR -> HALT!
So interpreter skips further code execution. I'd still like to know ways to solve that kind of issue.
The error:
Uncaught TypeError: Cannot read property 'model' of undefined.