alert() method shows an alert dialog with the optional detailed content and an OK button.
An alert box usually used in case we want to make sure information comes through to the user. Thealert() method shows a box with a message and an “OK” button.
When an alert box appears, the user will have to click "OK" to begin.
Example of the alert():
The window with the message is called a “modal” window. It means that the visitor can’t interact with the rest of the page or press other buttons until they have dealt with the window (press “OK”).
Alert dialog can be used for messages that do not require any reply on the part of the user, other than the acknowledgement of the message.
The prompt() method displays a dialog with an optional message reminding the user to input some text. It is often used in case the user wants to input a value before entering a page.
The function prompt accepts two arguments: title and default.
result = prompt(title, [default]);
Prompt shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel.
Title - is the text to show the visitor, and default - an optional second parameter, the initial value for the input field.
The visitor can type something in the prompt input field and press OK or cancel the input by pressing Cancel or hitting the Esc key. If the input was canceled, the call to prompt returns the text from the input field or null.
Example of the prompt():
The confirm() method displays a modal window with an optional message and buttons OK and Cancel. The result will be true if OK is pressed, otherwise it will be false.
Parameters: Accept a parameter that can be an object, an array, or any message.
Return value: Returns the value of the given parameter.
console.log() prints the component in an HTML-like tree