I think it might be related to the test using PhantomJS, that the test will fail due to some console.log
and I need to put a line:
var console = window.console;
at the top inside the IFFE, such as:
(function() {
var console = window.console;
// ...
}());
That is a bit strange. First of all, isn't PhatomJS based on webkit, and I thought console
and console.log
are both defined.
Second, I thought if window.console
is defined, and we set it using var console = window.console;
then actually, if we don't defined the local console
, when console
is encountered, then the browser will automatically resolve to window.console
because the global environment is window
?
I think if the console.log(...)
statements were replaced by window.console.log(...)
then var console = window.console;
won't be needed.
So why is the line var console = window.console;
needed and what does it help solve?