DEV Community

Discussion on: The Proper Way to Write Async Constructors in JavaScript

Collapse
 
andrade0 profile image
andrade0

Why # in attributes ? Never seen that before ?

Collapse
 
somedood profile image
Basti Ortiz

Oh, the # are for declaring private instance fields. They're a really neat feature if you want to keep your class variables secret.

Collapse
 
seedyrom profile image
Zack Kollar

There is no actual encapsulation in JavaScript, you can pretend there is by using the # syntax but it's just obfuscating values that can still always be accessed via the prototype.

Thread Thread
 
somedood profile image
Basti Ortiz

This is utterly false. Private class fields are inaccessible via the prototype.