Referring to javascript instance methods with a pound/hash sign

前端 未结 2 1934
温柔的废话
温柔的废话 2020-12-10 03:52

This question is similar to Why are methods in Ruby documentation preceded by a hash sign?

I understand why in Ruby instance methods are proceeded with a pound sign,

相关标签:
2条回答
  • 2020-12-10 04:47

    I think it comes from javadoc.

    http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#{@link}

    0 讨论(0)
  • 2020-12-10 04:48

    No, I have not yet met another JavaScript project that uses this notation.

    Something like this is useful in JavaScript, though, because unlike in many languages Class.methodName would refer to classmethods like String.fromCharCode, not instance methods which is what you are more often talking about. The method invoked by myinstance.methodName would be not MyClass.methodName but MyClass.prototype.methodName, and MyClass.prototype is an annoyance to keep typing.

    (The standard JS library confuses this by making many instance methods also have a corresponding classmethod. But they're different functions.)

    is it proepr for me to refer to instance methods in comments/documentation as SomeClass#someMethod?

    Do what you like/find most readable. There's no standard here.

    0 讨论(0)
提交回复
热议问题