Skip to content

DanielSasikumar/Static_Methods_in_Modern-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

And this gist provides simple js example of static within a class.

The class Arithmetic also defines add and sub as static functions. Regular methods treat a single object instance as self, but static methods are actually part of the class itself. This means you're able to call them on the class name (like Arithmetic. add(5,10)) If it isn't already apparent - the latter demonstrates that you can even access a class method without instantiating an object from the class first.

In this code, add and sub are then doing simple addition and subtraction. Since they

About

Static Methods in Modern Java Script

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published