Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js es6 class private method

class MyClass
{
  	// Prepend hash to make it private. Browser support at:
  	//	https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields#browser_compatibility
    // Dynamic access (ie: this.#[fieldName]) is disallowed by design.
  	#myPrivateMethod() {
    	// do private things
	}
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js #class #private #method
ADD COMMENT
Topic
Name
7+9 =