How to declare private attribute and methods in classes?

class transformer {
  name: 'Optimus Prime';
  #previousName: 'Orion Pax'; // private attribute

  rollOut() {

  // private method
  #transform() {

August 2nd, 2022

# Private class attributes and methods

Add to bookmarks

Until now, the convention was to use the _ for private attributes and methods. However, this had not been able to prevent the abuse.

To declare a private attribute or method, just put a # in front of it.