How to understand `JavaScript static methods are also not callable when the class is instantiated`

尤慕李

I read it on mdn. The original is:

The static keyword defines a static method for a class. Static methods are called without instantiating their class and are also not callable when the class is instantiated.

I thought static in js is similar to static in java but the sentence in question confuses me.

Amadan

It is similar. However, Java allows calling static methods on the instance:

p1.distance(p1, p2);

which does the same thing as

Point.distance(p1, p2);

The first one is not allowed in JavaScript.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

When a class template is instantiated, is a member template declaration also instantiated?

From Dev

When are vitual methods of a class template instantiated?

From Dev

When to use static and class methods

From Dev

Calling methods from a super class when a subclass is instantiated

From Dev

When using a static method, does the class every get instantiated?

From Dev

When using a static method, does the class every get instantiated?

From Dev

Java create a unique ID for each instantiated object using instance methods instead of class/static methods

From Dev

How to decorate class or static methods

From Dev

How to mock Python static methods and class methods

From Dev

Are members of a class template instantiated when the class is instantiated?

From Dev

How to make a distinction between static methods and instance methods when mocking a class?

From Dev

How to make a distinction between static methods and instance methods when mocking a class?

From Dev

When static variable be instantiated in Android

From Dev

Methods of second class on DBus not callable

From Dev

Static class variables are created when Static methods are being called - Java

From Dev

How to Know Static Methods's Class Name

From Dev

How to reference a provider in static class methods?

From Dev

Rails how do I check for existance of a class when not instantiated yet?

From Dev

How to create Abstract base class in JavaScript that can't be Instantiated

From Dev

Javascript: How to get the class, from which a certain object was instantiated?

From Dev

How to support static and class methods when passing positional arguments from a decorator?

From Dev

How can I safely convert a static class to an instantiated class in C#

From Dev

Are static members of a class template implicitly instantiated, or not?

From Dev

JavaScript - understand methods

From Dev

What are static methods? How and when are they used?

From Dev

How to have both static and instance methods in Javascript

From Dev

Why are classmethods blind to normal methods when instantiated?

From Dev

Get the static methods of a class

From Dev

Implementing Static Methods In A Class

Related Related

  1. 1

    When a class template is instantiated, is a member template declaration also instantiated?

  2. 2

    When are vitual methods of a class template instantiated?

  3. 3

    When to use static and class methods

  4. 4

    Calling methods from a super class when a subclass is instantiated

  5. 5

    When using a static method, does the class every get instantiated?

  6. 6

    When using a static method, does the class every get instantiated?

  7. 7

    Java create a unique ID for each instantiated object using instance methods instead of class/static methods

  8. 8

    How to decorate class or static methods

  9. 9

    How to mock Python static methods and class methods

  10. 10

    Are members of a class template instantiated when the class is instantiated?

  11. 11

    How to make a distinction between static methods and instance methods when mocking a class?

  12. 12

    How to make a distinction between static methods and instance methods when mocking a class?

  13. 13

    When static variable be instantiated in Android

  14. 14

    Methods of second class on DBus not callable

  15. 15

    Static class variables are created when Static methods are being called - Java

  16. 16

    How to Know Static Methods's Class Name

  17. 17

    How to reference a provider in static class methods?

  18. 18

    Rails how do I check for existance of a class when not instantiated yet?

  19. 19

    How to create Abstract base class in JavaScript that can't be Instantiated

  20. 20

    Javascript: How to get the class, from which a certain object was instantiated?

  21. 21

    How to support static and class methods when passing positional arguments from a decorator?

  22. 22

    How can I safely convert a static class to an instantiated class in C#

  23. 23

    Are static members of a class template implicitly instantiated, or not?

  24. 24

    JavaScript - understand methods

  25. 25

    What are static methods? How and when are they used?

  26. 26

    How to have both static and instance methods in Javascript

  27. 27

    Why are classmethods blind to normal methods when instantiated?

  28. 28

    Get the static methods of a class

  29. 29

    Implementing Static Methods In A Class

HotTag

Archive