From d9e9adb5f80a819fe46349bcf6d1faec734b09cd Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:07:31 +0800 Subject: remove span tag in zh-CN --- .../reference/statements/function/index.html | 36 +++++++++------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/statements/function') diff --git a/files/zh-cn/web/javascript/reference/statements/function/index.html b/files/zh-cn/web/javascript/reference/statements/function/index.html index 98d1073a9d..dc052a53d0 100644 --- a/files/zh-cn/web/javascript/reference/statements/function/index.html +++ b/files/zh-cn/web/javascript/reference/statements/function/index.html @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Statements/function -

语法

+

语法

function name([param,[, param,[..., param]]]) {
    [statements]
@@ -98,31 +98,23 @@ if (true) {
 
 

JavaScript 中的函数声明被提升到了函数定义。你可以在函数声明之前使用该函数:

-
hoisted(); // "foo"
+
hoisted(); // logs "foo"
 
-function hoisted() {
-     console.log("foo");
-}
-
-/* equal to*/
-var hoisted; 
-
-hoisted = function() {
-  console.log("foo");
-}
-hoisted();
-// "foo" 
+function hoisted() {
+  console.log('foo');
+}
 

注意 :函数表达式{{jsxref("Operators/function", "function expressions")}} 不会被提升:

-
notHoisted(); // TypeError: notHoisted is not a function
-
-var notHoisted = function() {
-   console.log("bar");
-};
+
notHoisted(); // TypeError: notHoisted is not a function
+
+var notHoisted = function() {
+  console.log('bar');
+};
+

示例

@@ -130,9 +122,9 @@ var hoistedfunction calc_sales(units_a, units_b, units_c) { - return units_a*79 + units_b * 129 + units_c * 699; -}
+
function calc_sales(units_a, units_b, units_c) {functionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunction
+   return units_a*79 + units_b * 129 + units_c * 699;
+}

规范

-- cgit v1.2.3-54-g00ecf