Variables & Basic Methods
let x = 10; Mutable variable
const y = 20; Immutable constant
console.log(x); Print in console
typeof x; Check data type
Strings
str.length String length
str.toUpperCase() Uppercase letters
str.includes('A') Check word existence
`Hi ${name}` Template Literal
Arrays
arr.push(x) Add to end
arr.pop() Remove from end
arr.map(x => x*2) Modify all elements
arr.filter(x => x>5) Filter elements
Functions
function f(x) {} Classic function
const f = (x) => {} Arrow function
return x; Function return
DOM Interaction
document.getElementById() Find by ID
document.querySelector() Find by CSS selector
el.innerHTML = '' Change HTML content
el.style.color = 'red' Change style
el.addEventListener() Listen to event
Asynchrony & Time
setTimeout(f, 1000) 1 second delay
setInterval(f, 1000) Repeat every 1 second
fetch(url).then() Fetch from server
async / await Manage async code
Management & Storage
localStorage.setItem(k, v) Save permanent data
localStorage.getItem(k) Read data
JSON.stringify() Convert object to string
try { } catch(e) { } Handle fatal errors