Why is a prompt inside an alert execute before the alert prompt?

This might be a newbie question, or just plain dumb because I might just not be realizing that this is jsut like the higher level functions, like currying or the other I forgot the name.

Anyways

alert(prompt().slice(0,250));

Why is prompt executed before alert?

The only thing I can think is that it’s a higher level function.

>Solution :

Your example has nothing to do with currying, or higher order functions.

You are passing an argument prompt().slice(0,250) to alert().

To know what to alert (or pass to whatever outer function is in place), the argument needs to be evaluated first.

Leave a Reply