I have a console wrapper that I've shared here before, if you're
interested -- http://jsfiddle.net/yx5a9/5/ .
For the record, my check is: |if (window.console && console[type] &&
console[type].apply) { ... }|. I've shared it here before, but its big
advantage is that it has a toString method; elsewhere, I've bound an
application alert to [Ctrl]+[Shift]+[`] that shows the results of
toString. It makes debugging in IE infinitely simpler. :)
On 05/01/11 21:45, Ger Hobbelt wrote:
On Sun, May 1, 2011 at 3:38 PM, Ger Hobbelt <[email protected]
<mailto:[email protected]>> wrote:
On Sun, May 1, 2011 at 3:13 PM, Steve Onnis
<[email protected] <mailto:[email protected]>> wrote:
Why don’t you use typeof(console.info <http://console.info>)
to make sure it is what you are expecting
Compare to the old skool browser sniff (if it's UA X then we got
B) indirect checks versus direct (does this bugger have method B?)
checks regarding DOM access functions.
BTW: if I'd been 100% anal/paranoid about it, it would have been this
check instead:
typeof(console) !== 'undefined' && typeof(console.info
<http://console.info>) !== 'undefined' && typeof(console.info.apply)
=== 'function'
where the last part /probably/ would have been done as
&& typeof(console.info.apply) !== 'undefined'
Since there's already one object in there (console.info
<http://console.info>) which you can treat as a function, I'd dial
expectations down as far as "you either get 'undefined' out of typeof
or some other crap" and code this with that mindset in charge.
--
Met vriendelijke groeten / Best regards,
Ger Hobbelt
--------------------------------------------------
web: http://www.hobbelt.com/
http://www.hebbut.net/
mail: [email protected] <mailto:[email protected]>
mobile: +31-6-11 120 978
--------------------------------------------------
--
Barry van Oudtshoorn
www.barryvan.com.au
Not sent from my Apple ?Phone.