let
const
const variable.var
// ✅ use const by default (var is not recommended)
let age =22// mutable
const name ="Hen"// immutable (most common)
this (object methods, constructors)argumentsthis to stay from the surrounding scopearguments or newfunction add (a, b) {
return a + b
}
this is dynamic (depends on how the function is called)
const obj = {
name: "Alex",
greet: function () {
console.log(this.name);
}
};
obj.greet(); // "Alex"
Can used as constructor
function Person(name) {
this.name = name;
}
const p = new Person("Alex"); // ✅ works
Do NOT enforce parameter count (can pass any number of arguments)
arguments.function sayHi() {
console.log("hi");
}
sayHi(1, 2, 3, 4); // ✅ still works
const add = (a, b) => {
return a + b
}