Jul 11, 2024
</body>
tag.let
and const
instead of var
.
let
: Reassignable.const
: Not reassignable.let age = 30; const name = 'John';
+
or template literals ${}
.length
, toUpperCase()
, toLowerCase()
, substring()
, split()
.[]
or new Array()
.push()
, unshift()
, pop()
, indexOf()
, isArray()
.const person = {
firstName: 'John',
lastName: 'Doe',
age: 30,
hobbies: ['music', 'sports'],
address: { street: '50 Main St', city: 'Boston' }
}
JSON.stringify()
to convert object to JSON.forEach()
, map()
, filter()
.&&
, ||
.condition ? expr1 : expr2
.const addNums = (num1, num2) => num1 + num2;
function Person(firstName, lastName, dob) {
this.firstName = firstName;
this.lastName = lastName;
this.dob = new Date(dob);
}
class Person {
constructor(firstName, lastName, dob) {
this.firstName = firstName;
this.lastName = lastName;
this.dob = new Date(dob);
}
getBirthYear() {
return this.dob.getFullYear();
}
}
getElementById()
, querySelector()
.getElementsByClassName()
, querySelectorAll()
.firstElementChild
, lastElementChild
, children
.textContent
, innerHTML
.style.property
.addEventListener()
, preventDefault()
.
Additional Resources: