"Alert is bad" - really?

javascript

Solution

Is there a solid, logical reason to never use alert()?

alert is bad simply because it has no positive features and only negative features

- blocks the entire browser

- blocks the javascript thread

- only prints strings

- requires user interaction to continue (this means you can't automate browser usage)

- is blocked by common popup blockers

- doesn't work in non-browser environments like node.js (however console.log does work in node.js)

Does the increased value of console.log() truly reduce the value of alert() so drastically that it goes from "useful in limited scenarios" to "bad"?

Yes, although there are some exceptions

The only value alert has is as a quick hackish tool to debug legacy browser or as a tool to annoy users.

Problem

There's this idea running around that "alert() is bad". Acknowledgements: - Sure, we rarely want to use it in an actual UI design since there are better ways to communicate with users. - For debugging, `console.log()` has much more value than `alert()`. - Certain situations (like use of `setTimeout`) run into problems when `alert()` gets in the way. - Actual debuggers handle pausing and resuming of execution much better than `alert()`, if that's what a developer needs. Questions: - Is there a solid, logical reason to never use `alert()`? - Does the increased value of `console.log()` truly reduce the value of `alert()` so drastically that it goes from "useful in limited scenarios" to "bad"? - What do you say to someone who wants to use `alert()` in a brief test where logging is not setup and any side effects are irrelevant (think tutorials or quick prototypes)?

Original source