Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS Syntax

JavaScript Syntax

JavaScript syntax delineates the guidelines for constructing JavaScript programs.

// How to create variables:
var x;
let y;

// How to use variables:
x = 5;
y = 6;
let z = x + y;

JavaScript Values

JavaScript syntax distinguishes between two types of values:

  • Fixed values, also known as literals.
  • Variable values, referred to as variables.

JavaScript Literals

One of the primary syntax rules for fixed values is:

1. Numbers can be expressed with or without decimals:

10.50

1001

2. Strings represent text and can be enclosed within either double or single quotes:

“John Doe”

‘John Doe’

JavaScript Variables

In programming, variables store data values. JavaScript uses keywords like varlet, and const for declaring variables, while the equal sign = is used to assign values.

In this instance, x is declared as a variable and subsequently assigned the value 6:

let x;
x = 6;

JavaScript Operators

JavaScript employs arithmetic operators ( + – * / ) to perform calculations and derive values.

(5 + 6) * 10

In JavaScript, an assignment operator ( = ) is utilized to assign values to variables.

let x, y;
x = 5;
y = 6;