JavaScript - Dialog Boxes

JavaScript provides several types of dialog boxes to interact with users, including:

1. alert: displays a simple message to the user and requires the user to click "OK" to proceed.

Example:

alert("Hello, welcome to JavaScript!");

2. confirm: displays a message with "OK" and "Cancel" buttons, and returns a Boolean value indicating whether the user clicked "OK" or "Cancel".

Example:

var result = confirm("Do you want to proceed?");

if (result === true) {

  // do something

} else {

  // do something else

}

3. prompt: displays a message and an input field for the user to enter text. It returns the text entered by the user or null if the user clicks "Cancel".

Example:

var name = prompt("Please enter your name:");

if (name) {

  // do something with the name

} else {

  // do something else

}