Signature (functions) - MDN Web Docs Glossary: Definitions of Web-related terms 编辑

A function signature (or type signature, or method signature) defines input and output of functions or methods.

A signature can include:

  • parameters and their types
  • a return value and type
  • exceptions that might be thrown or passed back
  • information about the availability of the method in an object-oriented program (such as the keywords public, static, or prototype).

In depth

Signatures in JavaScript

JavaScript is a loosely typed or a dynamic language. That means you don't have to declare the type of a variable ahead of time. The type will get determined automatically while the program is being processed. A signature in JavaScript can still give you some information about the method:

MyObject.prototype.myFunction(value)
  • The method is installed on an object called MyObject.
  • The method is installed on the prototype of MyObject (thus it is an instance method) as opposed to being a static method.
  • The name of the method is myFunction.
  • The method accepts one parameter, which is called value and is not further defined.

Signatures in Java

In Java, signatures are used to identify methods and classes at the level of the virtual machine code. You have to declare types of variables in your code in order to be able to run the Java code. Java is strictly typed and will check any parameters at compilation time if they are correct.

public static void main(String[] args)
  • The public keyword is an access modifier and indicates that this method can be called by any object.
  • The static keyword indicates that this method is a class method as opposed to being an instance method.
  • The void keyword indicates that this method has no return value.
  • The name of the method is main.
  • The method accepts one parameter of type String Array. It is named args.

Learn more

General knowledge

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:38 次

字数:3520

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文