[英]What is the difference between function declaration Vs. definition in JavaScript?
There are examples here with C++ and Java but it'll be great if someone can explain this with JavaScript examples.这里有 C++ 和 Java 的例子,但如果有人能用 JavaScript 例子解释这一点,那就太好了。 Also how is definition Vs.定义 Vs 也如何。 declaration works for variables.声明适用于变量。
There is no notion of " function definitions " in JavaScript. JavaScript 中没有“函数定义”的概念。 It does only distinguish between function declarations and function expressions (and the deprecated function statements ).它只区分函数声明和函数表达式(以及不推荐使用的函数语句)。
When we use the term "definition", it's typically meant as a hyperonym for both.当我们使用术语“定义”时,它通常是指两者的同义词。
It's similar for variables: there's only the term variable declaration in the standard, and when we use "variable definition" we either refer to that or the initialisation of the variable with a value (or both).它与变量类似:标准中只有术语变量声明,当我们使用“变量定义”时,我们要么指代它,要么指代变量的初始化(或两者)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.