How to Write Your First Program in JavaScript
Hello World Copy and paste the following HTML code in a file (e.g. Notepad) and save as "first.html" .
<!DOCTYPE HTML>
<html>
<body>
<script>
alert( 'Hello, world!!' );
</script>
</body>
</html>
After saving the file, double click the "first.html" file.
Then you will get a Message box with the message "Hello, world!!" .
The "Hello, World!" program is a classic and time-honored tradition in computer programming. JavaScript programs can be inserted in any part of an HTML document with the help of the < script > < /script> tag. The < script > tag is used to define a client-side script (JavaScript). The < script > tag alerts the browser program to start interpreting all the text between these tags as a script.
<script>
alert( 'Hello, world!!' );
</script>
An alert box is often used if you want to make sure information comes through to the user. Here, the alert() method displays an alert box with a specified 'Hello, world!!' message and an OK button.
Related Topics