I was listening to the Video “The JavaScript Programming Language” (1/4) by Douglas Crockford. Thought I would share few things that I’ve learned from this video which I didn’t know (or may be I forgot?). Presentation Slides are Here.

1. Type Coercion in Equal and not Equal ==, !== and ===, !===

2==2
//true

2=="2"
//true

2===2
//true

2==="2"
//false

It's been advised to use === and !== instead of == and !== for optimization and reliability. Hence, it avoids type coercion (typecasting).

2. bang bang (!!)

!!2
//true

!!0
//false

!!""
//false

**This is equal to Boolean() function

3. Unary Operator +

+"365"
//365

** Here '+' operator performs same thing as Number() function
4. Logical Operators - && and || are just like and & or operator in Python.

4 && 5 && 0 && 7
//0 - first faulty operand

0 || "" || 9 || 6
//9 - first truthy operand

will post the interesting things from the rest of his Videos. Ciao!

Tagged with:
 
  • Anonymous

    That’s awesome! Thanks! :)

  • http://www.ecommerce-web-developers.com/ ecommerce development

    Its a very useful information.Keep on posting such information soon your bloge will have a better rank

  • http://www.hire-web-developers.com/ hire a web developer

    A very good and a interesting blog.
    Thanks for sharing.