JavaScript static MethodThe JavaScript provides static methods that belong to the class instead of an instance of that class. So, an instance is not required to call the static method. These methods are called directly on the class itself. Points to remember
JavaScript static Method Example 1Let's see a simple example of a static method. Test it NowOutput: static method is invoked Example 2Le's see an example to invoke more than one static method. Test it NowOutput: static method is invoked static method is invoked again Example 3Let's see an example to invoke more than one static method with similar names. Test it NowOutput: static method is invoked again Example 4Let's see an example to invoke a static method within the constructor. Test it NowOutput: static method is invoked static method is invoked Example 5Let's see an example to invoke a static method within the non-static method. Test it NowOutput: static method is invoked
Next TopicJS Encapsulation
|
Javatpoint provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India