Open stkevintan opened 6 years ago
Sorry for the delay. I think the reason there is so much ceremony around a simple console.warn
is to protect against environments that do not have access to console
.
Without using global
checking for the presence of console
is difficult, e.g. just doing the following will lead to a ReferenceError
:
if (console && console.warn) {
// ..snip...
}
If there is a way to perform this check without being broken by strict mode?
@olivernn
if ((typeof console !== 'undefined') && console.warn) {
// ...
}
will this be addressed any time soon?
I'm using lunr with es6 syntax which need babel to compile. but babel will always enable the strict mode which will make an error in following source code:
this
in strict mode will be undefined instead of thewindow
object .By the way, I don't understand why using
global.console
instead ofconsole
, is it necessary for some edge case?