Open In App

What is the use of the Alert Function in JavaScript ?

Last Updated : 29 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The alert function in JavaScript is used to display a modal dialog box with a message and an OK button. It is commonly used for providing information to the user or displaying alerts for various purposes.

Example: Here, When this script runs, it will display a dialog box with the message “Hello, this is an alert!” and an OK button. The user cannot interact with the page or perform any actions until they click the OK button in the alert dialog.

Javascript




alert("Hello, this is an alert!");



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads