Answers for "Private slots are new and can be created via Private methods and accessors"

0

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();
Posted by: Guest on March-25-2022

Code answers related to "Private slots are new and can be created via Private methods and accessors"

Code answers related to "Javascript"

Browse Popular Code Answers by Language