A “Hello, World!” is a simple program that prints Hello, World! on the screen. Since it’s a very simple program, this program is often used to introduce a new programming language to beginners.
We will use these three ways to print ‘Hello, World!’.
// the hello world program console.log('Hello World'); a = 10; console.log('Value of a is: ', a);
Hello, World! Value of a is: 10
Here, the first line is a comment.
// the hello world program
The alert() method displays an alert box over the current window with the specified message. This method could be use to show some message to user, to as some input from user.
// the hello world program alert("Hello, World!");
document.write() is used when you want to print the content to the HTML tags. Such as input box, text area, div or table etc.
// the hello world program document.write('Hello, World!');