In this video we look at the recently added (well stage 3 TC39 proposal) private class fields that can now be used in Javascript. This new language feature is available in Chrome 74, NodeJs 12 and both Typescript and Babel. So good to use today if you are bundling with either Typescript or Babel in your pipeline, are targeting just Chrome or Node. The other browsers will not be far behind, and as Edge is now Chromium based I'm guessing this is enabled in there already now too.
Private fields give us the ability to encapsulate the inner workings of a class by denying access to them from consumers of the class. This aids in the maintainability of the class as we can change the internal workings without worry of breaking some existing applications that rely on said workings.
They are specified by the '#' character, a somewhat strange choice it would appear, but one made to ensure that existing JavaScript applications are not broken in any way.
TC39 Docs for some more details and examples:
https://github.com/tc39/proposal-clas...
Смотрите видео Private class fields in Javascript are here! онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь A shot of code 12 Март 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 5,587 раз и оно понравилось 262 людям.