Alert Box : An alert box is primarily used to ensure that users receive information. You must select “OK” on an alert window to continue.
Confirm Box : A confirm box is often used by the user to confirm or approve something. To continue, the user must select “OK” or “Cancel” from the confirm box that appears. The box returns true if the user selects “OK”. The box returns false if the user hits “Cancel.”
Prompt Box : The user enters a value into a prompt box before proceeding to a page. The user must click “OK” or “Cancel” to continue after giving an input value in a prompt box that appears. The input value is returned to the box if the user hits “OK.” It returns null if the user hits the “Cancel” button.
The alert box causes the browser to view the message while diverting attention from the currently active window. Because it restricts the user from accessing other areas of the website until the box is closed, you should avoid utilizing this technique excessively.
Here, the message is either an object that has been turned into a string and shown, or it is a string type that specifies the text to display in the alert box. It’s not required.
alert(“This is an Alert!”);
Once you double-click on the button, you will get the alert message as follows