Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading