JavaScript Syntax

JavaScript Statements

JavaScript statements are instructions to be executed by the browser. They can perform actions like displaying output, making calculations, or manipulating the DOM. Each statement is usually separated by a semicolon (;).

Explanation of Code:

Tutorials dojo strip

Each line in the example below is a JavaScript statement. The last statement uses console.log to output the value of z.

JavaScript

Case Sensitivity

JavaScript is case-sensitive, meaning myVariable and myvariable are considered two different variables.

Explanation of Code:

The example demonstrates that myVariable and myvariable are treated as separate variables.

JavaScript

Whitespace and Indentation

JavaScript ignores extra spaces, tabs, and newlines, which means you can format your code for better readability without affecting its execution.

Exaplanation of Code:

The code uses indentation and spaces to make it more readable.

JavaScript

JavaScript Keywords

Keywords are reserved words that have special meaning in JavaScript. They are used to perform specific actions. Examples include varletconstifelseforwhilefunction, and return.

JavaScript

JavaScript Syntax Example Code

Explanation of Code:

  • Variables: Declared using let.
  • Comments: Used both single-line and multi-line comments.
  • Statements: Each statement ends with a semicolon.
  • Outputconsole.log displays the result in the console.
HTML

JavaScript Labs

Tutorials dojo strip