1. alert
shows a message.
alert("Hello");
2. prompt
shows a message asking the user to input text or null.
var name = prompt("What is your name?");
Note: You can add an optional second parameter, the initial value for the input field.
var name = prompt("What is your name?", "John");
3. confirm
shows a message and waits for the user to press "OK" or "Cancel". It returns "true" for OK and "false" for Cancel.
var confirmation = confirm("Are you sure?");
Top comments (0)