• Авторизация


Spidermonkey Development Blog: Private Fields and Methods ship with Firefox 90 03-05-2021 18:30 к комментариям - к полной версии - понравилось!


Firefox will ship Private Fields and Methods in Firefox 90. This new language syntax allows programmers to have strict access control over their class internals. A private field can only be accessed by code inside the class declaration.

class PrivateDetails {
  #private_data = "I shouldn't be seen by others";

  #private_method { return "private data" }

  useData() {
    /.../.test(this.#private_data);

    var p = this.#private_method();
  }
}

var p = new PrivateDetails();
p.useData(); // OK
p.#private_data; // SyntaxError

This is the last remaining piece of the Stage 4 Proposal, Class field declarations for JavaScript, which has many more details about the design of private data.

https://spidermonkey.dev/blog/2021/05/03/private-fields-ship.html

вверх^ к полной версии понравилось! в evernote


Вы сейчас не можете прокомментировать это сообщение.

Дневник Spidermonkey Development Blog: Private Fields and Methods ship with Firefox 90 | rss_planet_mozilla - Planet Mozilla | Лента друзей rss_planet_mozilla / Полная версия Добавить в друзья Страницы: раньше»