From 01b0e12ba27b5069248fd09235e9a7143915ee30 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:02:49 +0800 Subject: remove `notranslate` class in zh-CN --- .../web/javascript/reference/statements/function/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 dc052a53d0..0ab978503d 100644 --- a/files/zh-cn/web/javascript/reference/statements/function/index.html +++ b/files/zh-cn/web/javascript/reference/statements/function/index.html @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Statements/function

语法

-
function name([param,[, param,[..., param]]]) {
+
function name([param,[, param,[..., param]]]) {
    [statements]
 }
 
@@ -55,7 +55,7 @@ translation_of: Web/JavaScript/Reference/Statements/function

函数可以被有条件来声明,这意味着,函数声明可能出现在一个 if 语句里,但是,这种声明方式在不同的浏览器里可能有不同的效果。因此,不应该在生产环境代码中使用这种声明方式,应该使用函数表达式来代替。

-
var hoisted = "foo" in this;
+
var hoisted = "foo" in this;
 console.log(`'foo' name ${hoisted ? "is" : "is not"} hoisted. typeof foo is ${typeof foo}`);
 if (false) {
   function foo(){ return 1; }
@@ -75,7 +75,7 @@ if (false) {
 
 

注意,即使把上面代码中的 if(false) 改为 if(true),结果也是一样的

-
var hoisted = "foo" in this;
+
var hoisted = "foo" in this;
 console.log(`'foo' name ${hoisted ? "is" : "is not"} hoisted. typeof foo is ${typeof foo}`);
 if (true) {
   function foo(){ return 1; }
@@ -98,7 +98,7 @@ if (true) {
 
 

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

-
hoisted(); // logs "foo"
+
hoisted(); // logs "foo"
 
 function hoisted() {
   console.log('foo');
@@ -109,7 +109,7 @@ function hoisted() {
 

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

-
notHoisted(); // TypeError: notHoisted is not a function
+
notHoisted(); // TypeError: notHoisted is not a function
 
 var notHoisted = function() {
   console.log('bar');
@@ -122,7 +122,7 @@ var notHoisted = function() {
 
 

下面的代码声明了一个函数,该函数返回了销售的总金额, 参数是产品a,b,c分别的销售的数量.

-
function calc_sales(units_a, units_b, units_c) {functionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunction
+
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