JavaScript Window alert() method

The alert() method in JavaScript is used to display a message to the user. This method takes a string argument that specifies the message to be displayed, and displays an alert dialog box with the specified message. The alert() method blocks further execution of the script until the user dismisses the alert dialog box.

Here is an example of how the alert() method works:

const string1 = 'Hello, world!';

alert(string1);

// this will display an alert dialog box with the text 'Hello, world!'

In the code example above, we first declare a string called string1 that contains the text Hello, world!. We then use the alert() method to display an alert dialog box with the string1 string as the message. We pass the string1 string as an argument to the alert() method to specify the message to be displayed.

As a result of calling the alert() method, an alert dialog box will be displayed with the text Hello, world!. The execution of the script will be blocked until the user dismisses the alert dialog box.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: