JAVASCRIPT TUTORIAL
Our Projects
Syntax Of JavaScript – Basics Every Beginner Should Know
JavaScript syntax is the set of rules, how JavaScript programs are constructed:
// How to create variables:
var x;
let y;
// How to use variables:
x = 5;
y = 6;
let z = x + y;
JavaScript Values
The JavaScript grammar specifies two types of values:
- Fixed values.
- Variable Values
Fixed values are referred to as literals.
Variable values are referred to as Variables.
JavaScript Literals
The two primary syntactic rules for fixed values are:
1. Numbers can be written with or without decimals.
10.50
1001
2. Strings are text enclosed between double or single quotes:
“John Doe”
‘John Doe’
JavaScript Variables
In a computer language, variables are used to store data.
To declare variables in JavaScript, use the keywords var, let and const.
The equal sign is used to assign values to variables.
In this example, x is treated as a variable. Then, x is assigned (given) the value six.
let x;
x = 6;
JavaScript Operators
JavaScript uses arithmetic operators ( + - * / ) to compute values:
To assign values to variables in JavaScript, use the assignment operator ( = ).
let x, y;
x = 5;
y = 6;
JavaScript Keywords
Actions to be taken are identified using JavaScript keywords.
The browser is instructed to create variables using the let keyword: