at method
const array = [1, 2, 3];
const oldLast = array[array.length - 1];
const newLast = array.at(-1)
'1234'.at(-1)
Top-level await
const fetchData = async () => {
const res = await axios.get('...');
}
fetchData();
const res = await axios.get('...');
Class Fields
class Person {
constructor() {
this.name = 'flynn'
}
name = 'flynn'
}
Private Fields
class Person {
_name = 'flynn'
get name() {
return this.name;
}
#name = 'flynn'
get name() {
return this.#name;
}
}
const person = new Person();
person._name
person.#name
Static Field
class Circle {}
Circle.PI = 3.14
class Circle {
static PI = 3.14
}