Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Private slots are new and can be created via Private methods and accessors

// ES2022
class MyClass {
  #privateMethod() {}
  static check() {
    const inst = new MyClass();

    console.log(#privateMethod in inst) // output-> true

    console.log(#privateMethod in MyClass.prototype) // output-> false

    console.log(#privateMethod in MyClass) // output-> false
  }
}
MyClass.check();
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #Private #slots #created #Private #methods #accessors
ADD COMMENT
Topic
Name
4+8 =