JavaScript static Method

Static methods in JavaScript is a way for providing class level methods. To declare a static method, we have to use static keyword as prefix with method name.

class className(){
   static methodName(){
      //method body

Ways to call static methods

1. Using Class name


2. On the constructor property of the class


Points to remember:

  • Static keyword is used as prefix with method name to declare a static method.
  • We can call static method without instantiating the class.
  • We can declare more than one static method in a class but if these have a similar name then JavaScript engine always invokes the last one.
  • The static method are commonly used to create utility functions for an application.
  • this keyword can be used to call a static method within another static method but we this keyword can not be used directly to call a static method within the non-static method. For these situations we either have to use the class name or as the property of the constructor like this.constructor.methodName().


<!DOCTYPE html>
class CollegeName
  {"NC College";
class Student extends CollegeName{
  constructor(rollNo,name) {
var stu= new Student(1,"Sue");
document.writeln(stu.rollNo+" "" ";


Hello World!
Please Share