how to display 'hello world' in console using JavaScript

Use console.log() method

In order to display ‘hello world’ in console using JavaScript, you need to use console.log() method in your script tag.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Display 'hello world' in console using JavaScript</title>
<script>
console.log('Hello World');
</script>
</head>
<body>
<p>This is how to display 'hello world' in console using JavaScript</p>
</body>
</html>

Then you can see ‘Hello World’ text on your browser console window.

Share