Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JS basic operators

// Math Operators
const now = 2022;
const age1 = now - 1994;
const age2 = now - 2000;

console.log(age1 * 2, age1 / 10, 2 ** 3);
// 2 ** 3 = 2 * 2 * 2

// Assigment Operators
let x = 10 + 5; //15

x += 10; // x = x + 10 = 25
x *= 4; // x = x * 4 = 25 * 4 = 100
x /= 5; // x = x / 5 = 100 / 5 = 20
x++; // x = x + 1
x--; // x = x - 1

// Comparison Operators
const isFullAge = age2 >= 18;
 
PREVIOUS NEXT
Tagged: #JS #basic #operators
ADD COMMENT
Topic
Name
1+8 =