In this video, we will write a Javascript program to print Hello world.
Here in this program to print the ‘Hello World’ sentence to the screen, we use three different methods that javascript provides:
1. console.log(): The console.log() is a function in JavaScript which is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.
Syntax: console.log(A);
Example: console.log(GeeksforGeeks);
2. alert(): Alert shows an alert box to the user with a message that the user has to press "Ok" to continue using the website.
Syntax: alert(“Message”);
Example: alert(“GeeksforGeeks”)
3. document.write(): A document.write() is used when we want to print the content to the HTML document. The document.write prints something directly to the website and don't require user interaction.
Syntax: document.write(" Message ");
Example: document.write(" GeeksforGeeks");
JS program to print hello world:
https://www.geeksforgeeks.org/javascript-course-printing-hello-world-in-javascript/