JavaScript Syntax

JavaScript Syntax specifies the set of rules for constructing a JavaScript program.
The is used to write JavaScript statements. The script tag can be used anywhere in the head or body but it is a good practice to use it within the tag.

Syntax:

<script language="javascript" type="text/javascript">
//JavaScript statements
</script>

Attributes:

language: represents the Java script language.
type: represents the content type.

Important points:

1. It is a case-sensitive language.
2. JavaScript statements will be followed by a semicolon.

Syntax:

<script language="javascript" type="text/javascript">
num1 = 100; num2 = 200;
</script>

Semicolons can be omitted if JavaScript statements are in a different line.

Syntax:

<script language="javascript" type="text/javascript">
num1 = 100
num2 = 200
</script>