Что нас ждет дальше? Этот вопрос время от времени возникает в различных сферах жизни, говоря же о вебе, мы рассуждаем над тем кто-же будет следующим большим игроком WebAssembly или технология X, вместе с тем на данный момент JavaScript занимает львиную долю на рынке и отступать не собирается. Какие изменения ждут JS в ближайшем будущем? Приходи и узнай!
42. Reasons to use # instead of private
Same public and private fields
class Foo {
private baz;
public baz;
method() {
this.baz;
this.baz;
}
}
43. Reasons to use # instead of private
Public fields in JavaScript can be referenced via this.field or this.['field'].
class Foo {
…
}
const foo = new Foo();
foo['field'] // works just for static fields
44. Reasons to use # instead of private
You'd need expensive checks
equals(other) { // other could be anything
return this.#x === other.#x && this.#y === other.#y;
}