Edit

JavaScript Syntax

The JavaScript syntax describe the structure of JavaScript program. A JavaScript consists of JavaScript statements that are placed within the <script></script> HTML tags in a web page, or within the external JavaScript file having .js extension.

JavaScript Values

The JavaScript has two types of values which are following.

1. Fixed values 

Fixed values are called literals.

2. Variable values.

Variable values are called variables. An equal sign is used to assign values to variables.

JavaScript Keywords

JavaScript keywords are used to identify actions to be performed.

The var keyword tells the browser to create variables in the following example.

<p id="keyword"></p>
<script>
var a, b;
a = 10 - 4;
b = a * 10;
document.getElementById("keyword").innerHTML = b;
</script>

Output

JavaScript Identifiers

Identifiers are names. In JavaScript, identifiers are used to name variables (and keywords, and functions, and labels).

Case Sensitive

All JavaScript identifiers are case sensitive. This means that variables, language keywords, function names, and other identifiers must always be typed with a consistent capitalization of letters. The variables lastName and lastname, are two different variables:

For example

<script>
    var testVar = "Hello World!";
    console.log(testVar);
    console.log(TestVar);
    console.log(testvar);
</script>
<p><strong>Note:</strong> Check out the browser console by pressing the f12 key on the keyboard, you'll see a line something like this: "Uncaught ReferenceError: TestVar is not defined".</p>

Output

Note: Check out the browser console by pressing the f12 key on the keyboard, you'll see a line something like this: "Uncaught ReferenceError: TestVar is not defined".