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
1. Using console.log()
console.log() is used in debugging the code.
// the hello world program console.log('Hello World');
Here, the first line is a comment.
// the hello world program
The second line
prints the ‘Hello, World!’ string to the console.
2. Using alert()
alert() method displays an alert box over the current window with the specified message.
// the hello world program alert("Hello, World!");
3. Using document.write()
document.write() is used when you want to print the content to the HTML document.
// the hello world program document.write('Hello, World!');
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.