On Wed, Apr 13, 2011 at 11:55 PM, J.R. <[email protected]> wrote:
> On Tuesday, 12 April 2011 02:12:31 UTC-3, Angus Croll wrote:
>>
>> Douglas Crockford is a JavaScript hero and a great communicator. I learned
>> a lot from his writings and his excellent video series
>> (http://net.tutsplus.com/tutorials/javascript-ajax/crockford-on-javascript-the-complete-series/)
>>
>> We all make mistakes and I'm sure I make more mistakes than Douglas. But
>> then Douglas is in a unique position - a generation of JavaScript students
>> have grown up quoting his "Crocklamations", insisting that Douglas knows
>> best because, after all the Good Parts is The JavaScript Bible.
>>
>
> "Crocklamations" ?!?! Brilliant !!! :-D
>
>
>> But, just like anyone, Douglas can get it wrong. Sometimes very wrong.
>
> Yeah! Like his last "Crocklamation" that "IE9 must die":
> <http://3.bp.blogspot.com/-sMuOcQTWxbQ/TZsLSQZgPDI/AAAAAAAAAAM/DHpYv-GRv-4/s320/ie9mustdie.jpg>
>
>
>>
>> On page 121 of The Good Parts, in the section "== and !=" Douglas says:
>>
>> If you want the type coercion, then use the short form. Instead of:
>>
>> (foo != 0)
>>
>> just say
>>
>> (foo)
>>
>
> DC is right if we just need to test for Undefined, Null, +0, -0, NaN, and ""
> (empty string), according ECMA-262 3rd ed. sections 9.2 (ToBoolean) and 12.5
> (The if Statement). It's common place to use just:
> If (foo) { ... }
> instead of:
> if (typeof foo !== "undefined") { ... }
> In a different test other than the above, then we should be more careful.
> For instance:
> Instead of:
> if (window.ActiveXObject) {
> We should use:
> if (typeof window.ActiveXObject !== "undefined") {
>
If the objective is testing existence of the named member/property
then use the 'in' operator:
if ('ActiveXObject' in window) { ... }
it is shorter and avoids comparing its value (which may imply a type
conversion).
--
Diego
>>
>> <snip>
>>
>> And this is why its dangerous to put all your faith in one teacher,
>> however brilliant. Question everything (including me!) and follow your own
>> path.
>
> I totally agree with you!
> --
> JR
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]