Copyright (c)2023 Promineo Tech
Promineo Tech Academic Team
var x = "value";
let y = "value";
const z = "value"; (constant, can not be changed)
• Number (e.g. 42)
• String (e.g. "Goodbye World")
• Boolean ( e.g. true/false)
• Undefined (e.g. undefined)
• Null (e.g. null)
• Object (e.g. {})
• Array (e.g. [1,2,3,4,5])
var arr = [element1, element2, element3];
• arr.push(element)
• arr.pop()
• arr.shift()
• arr.unshift(element)
• arr.slice(start, end)
• arr.splice(index, deleteCount, element)
• Arithmetic: +, •, *, /, % (modulo)
• Assignment: =, +=, •=, *=, /=, %=
• Comparison: ==, ===, !=, !==, >, <, >=, <=
• Logical: &&, ||, !
if (condition) {
statements;
} else {
statements;
}
switch (expression) {
case x: statements;
break;
case y: statements;
break;
default: statements;
}
for (var i = 0; i < 10; i++) {
statements;
}
while (condition) {
statements;
}
do {
statements;
} while (condition);
function name(param1, param2) { statements; }
(param1, param2) => { statements; }
var obj = { key1: value1, key2: value2 };
• element.addEventListener("eventType", function() { statements; });
button.addEventListener("click", function() { alert("Button clicked!"); });
document.getElementById("id"), document.querySelector("css selector")
element.innerHTML = "new content";
element.style.property = "new value";
str.replace("old", "new")