note 1
Function length property
This took me an hour to understand but
basically the code in the ts file uses the
function.length property to
deterimine what kind of behavior the calling
function -- that requires function definitions
as arguments -- will be called, relative to
the parameters in their signature.
In this case, for example,
handler functions that are
defined at the ask function's
call time, are checked whether they were
defined with parameters or not; done through
the handler function's
.length property and if they were
defined with parameters to always pass the
confirm's result into them as an
argument, and then do something with the
return type (I actually haven't really
understood exactly whether they specifically
wanted a return type or just wanted to alert
the argument passed but i'm just logging it my
decision, the explanation is cumbersome),
otherwise, if it wasn't defined with
parameters then it will only be ran if the
value of the confirm function was
true.