Javascript tutorials

Today I learned few things in javascript

if( value ) {}
will evaluate to true if value is not:
  • null
  • undefined
  • NaN
  • empty string ("")
  • 0
  • false


!! operator in node js

This converts a value to a boolean and ensures a boolean type.

"foo"      =    "foo"
!"foo"     =    false
!!"foo"    =    true

Truth Table for javascript

''        ==   '0'           // false
0         ==   ''            // true
0         ==   '0'           // true
false     ==   'false'       // false
false     ==   '0'           // true
false     ==   undefined     // false
false     ==   null          // false
null      ==   undefined     // true
" \t\r\n" ==   0             // true
NaN   ===  NaN     //false
!!NaN === !!NaN    //true

Comments

Popular posts from this blog

Proxy setting in java

Using logstash to import csv json files into elasticsearch

Kibana 4 Installation and Run as a service in ubuntu