JavaScript Syntax

The JavaScript syntax refers to the rules that define the structure of a JavaScript program.

Syntax: All the JavaScript statements are positioned in the <script> </script> HTML tags in a web page.

Example

.lang-js
var x = 10;

var y = 15;

var total = x + y;

document.write(total);

Is JavaScript case-sensitive?

Yes, JavaScript is a case-sensitive language. This implies that you need to type the keywords, variables, and function names with capital letters.

For instance: You cannot type the getElementById( ) method as getElementBYID().

Example

.lang-js
var myVar = "Introduction to JavaScript"

console.log(myVar);

console.log(MyVar);

console.log(myvar);

When you run the above code, you will get an error message: "Uncaught ReferenceError: MyVar is not defined".