javascript - how does the inside of "if (console.clear)" evaluate to true? -


i'm using code skip clearing console in safari, because function not defined in safari

if (console.clear) { console.clear() }; 

but how "console.clear" ever evaluate true? outputs don't true.

console.log(console.clear);  // undefined                                safari // function()                               ff // function clear() { [native code] }       opera, chrome, ie 

if target not 1 of these, returns true in if statement:

'', (+-)0, null, undefined, nan, false 

Comments