There is no difference between console.log
and window.console.log
.
Have a check on MDN. They clearly quote -
The Console object can be accessed from any global object, Window on
browsing scopes, WorkerGlobalScope, and its specific variants in
workers via property console. It's exposed as Window.console
, and
can be referenced as simply console
.
Adding to this, the question may have also been-
What's the difference between console.log
and window.console
.
The answer for this would be-
console.log
is used for logging(as you know).
window.console
checks if the console is available(truthy
value) so that we can log next.(in case of mobile browsers, they don't support debugger/console)
Common pattern in code for this is-
window.console && console.log(open_date);
Which is basically short code for -
if( window.console ) {
console.log( open_date );
}