if(console && typeof console.warn == "function"){ ... }
,
this
:.
if(this.console){
console.warn("shhaabang");
}
EDIT: , , 2 :
1) , this
... @
2) strict mode
, strict mode
, this
undefined
:
var c;
try {
c = console;
} catch(e){
// console is not defined
}
if(c) {
// console is defined
}else{
// this will not throw because you declared `c` earlier
}