Skip to main content
added 30 characters in body
Source Link
cocco
  • 16.8k
  • 7
  • 65
  • 77

With a return value.. you negate that with !

var x=!function(){return false}(); console.log(x); // true 

double negation

var pizza='pizza'; var x=!!function(){return pizza}(); console.log(x); // true  // returns true if pizza is defined, not 'pizza' // returns false if pizza is ''. 

demo

http://jsfiddle.net/9shzF/http://jsfiddle.net/9shzF/1/

With a return value.. you negate that with !

var x=!function(){return false}(); console.log(x); 

double negation

var pizza='pizza'; var x=!!function(){return pizza}(); console.log(x); // returns true if pizza is defined // returns false if pizza is ''. 

demo

http://jsfiddle.net/9shzF/

With a return value.. you negate that with !

var x=!function(){return false}(); console.log(x); // true 

double negation

var pizza='pizza'; var x=!!function(){return pizza}(); console.log(x); // true  // returns true if pizza is defined, not 'pizza' // returns false if pizza is ''. 

demo

http://jsfiddle.net/9shzF/1/

Source Link
cocco
  • 16.8k
  • 7
  • 65
  • 77

With a return value.. you negate that with !

var x=!function(){return false}(); console.log(x); 

double negation

var pizza='pizza'; var x=!!function(){return pizza}(); console.log(x); // returns true if pizza is defined // returns false if pizza is ''. 

demo

http://jsfiddle.net/9shzF/