Skip to content

Instantly share code, notes, and snippets.

@mssoheil
Last active November 4, 2023 15:30
Show Gist options
  • Select an option

  • Save mssoheil/cb333f3d348702847b68bea362fe29f4 to your computer and use it in GitHub Desktop.

Select an option

Save mssoheil/cb333f3d348702847b68bea362fe29f4 to your computer and use it in GitHub Desktop.
Tags: JavaScript
Private methods: are only accessible inside the class that they are defined.
Protected methods: are only accessible inside the class that they are defined and also accessible inside
of any class that extends their class.
Static methods and properties: are not accessible on instance of their class(`new keyword`) and only accessible directly on the class(`MyClass.method`)
and inside their class are only accessible
inside of another static property (unless we don't use the this keyword).
for e.g. Math Class. we add static keyword to the method inside the class
Abstract classes: When we want to force that a method exists in a class that extends the class
we add abstract key to that method and also abstract keyword to the class itself so the class will become abstract class
and the abstract method should not have curly braces --> abstract myMethod(this);
also the abstract class can't be instantiated and have to extend them
extends vs implements: extends inherits all of the properties and methods but implements force us to create a class that looks like
the class(interface) that it implements from so if a property is in the class,
the implemented class MUST have those too so the class will become an interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment