function foo(bar){ return !bar; } (false) ? false : true
looks like:
if(false){ //false } else { //true }
your function is not called, and your condition is false , that is, it returns the second operator (which has //true ).
the second is VERY different
(function foo(bar){ return !bar; } (false) ? false : true)
as follows:
function foo(bar){ return !bar; } var temp = foo(false) if(temp){
you technically create a function self-executing function expressions (IFFE) are invoked immediately using the false as parameter. what he returns obeys the condition. So:
- you passed
false as a parameter - the function returns the inverse that is
true - the result is computed, and since return is
true , it executes the first statement of your condition (which has //false )
self- executing functions immediately called function expressions (IFFEs) usually have these forms and are usually used for closing forms (which is beyond the scope of this question)
var result = (function(innerParam){ //function body }(passedParam)); and //this form commonly seen in jQuery plugins var result = (function(innerParam){ //function body })(passedParam);
source share