Why it does return a function but not what the function returns

Please consider the following code below:

function fun() {
  
return (true)
         ? () => true //This one returns a function instead of true
         : false
  ;
}

To call the function returned, you would have to write:

fun()(); // true

Or you could rewrite to execute the function when it is defined:

function fun() {
  
return (true)
         ? (() => true)()
         : false
  ;
}

fun(); // true
3 Likes

Thanks man :grinning_face_with_smiling_eyes: :heart: