In this example we will see how to print “Hello World” in the console and also different ways to print “hello world”. There are three ways we can print hello world in javascript. They are,
- console.log()
- alert()
- document.alert()
Using Console.log() method
Console.log is mostly used for debugging the code.
<script>
console.log("Hello World")
</script>
Using alert() method
alert() method is used to display alert box in the browser window and display the alert message given within the double quote of the alert() function
<script>
alert("Hello World")
</script>
Using document.write() method
document.write() method is used to write the content in the HTML document.
<script>
document.write("Hello World")
</script>
check out my other blogs with given link 👇