Alert and prompt are the methods for user interaction in Jav

Alert() and \"prompt()\" are the methods for user interaction in Java Script. Differentiate between them, give an example declaration/usage, describe their limitations and which popular browsers from the following support them. The popular browsers could be: Mozilla Firefox, Internet Explorer, MS Edge, Google Chrome, Safari and Opera.

Solution

Difference between alert and prompt:
alert() dialog
The alert() dialog box is used to communicate a message to the user (generally warnings of missed actions). For example, if the email address entered is wrong,
you can use the alert() message to warn the user about it. Developers also use alerts() as a quick and dirty way to debug their applications.
// warning
alert(\"Invalid email address. Please enter again.\");
// debugging
alert(currentCounter);
The alert() method creates a new pop-up window (dialog box) which contains the user message and an
OK button. This is a modal window and all execution is stopped until the user clicks the OK button in the pop-up box.

prompt() dialog
The prompt() method asks the user for some small input such as a password, completion of a form input, or personal information, such as nickname or title. The
prompt dialog box pops up with a simple text box. After the user enters text into the prompt dialog box, its value is returned (or null in case the user hit
cancel).
prompt(\"Please enter your nickname\", \"nickname\");
The prompt method takes in 2 arguments – the prompt message and a default value. The default value is optional and if provided is filled in the text box and is
selected by default.

Supported browsers:
Chrome, Mozilla, Opera, IE, Safari and i dont know abount MS Edge

 Alert() and \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site