JavaScript Tutorial - Hello World

Jinku Hu Oct 12, 2023
  1. JavaScript Hello World
  2. Basic JavaScript Syntax Rules
JavaScript Tutorial - Hello World

In this tutorial, we’re going to do a simple Hello World program in JavaScript as the starting point of our JavaScript tutorial.

JavaScript Hello World

<!DOCTYPE HTML>
<html>

<body>

  <p>JavaScript Tutorial</p>

  <script>
    alert( 'Hello, world!' );
  </script>

</body>

</html>
<script>
	alert( 'Hello, world!' );
</script>

When we embed JavaScript in a web page, we always have to embed it within the script tags <script>...</script>.

alert('Hello, world!');

It is simply an alert with information Hello World! within the parenthesis, and then it ends with a semicolon.

If you save the above code to a file named like helloworld.html and then view it in a browser, you will get a pop-up box saying Hello world!.

Basic JavaScript Syntax Rules

Before we continue to learn JavaScript further, we should get some basic syntax rules of this scripting language.

  • JavaScript is case sensitive. It is valid for both variables and functions.
  • Each statement ends with a semicolon.
Author: Jinku Hu
Jinku Hu avatar Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

LinkedIn Facebook