From 012ee621791b6895e637f96e6523027951768f25 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:03:27 +0800 Subject: remove inline style for zh-CN --- .../javascript/reference/statements/function/index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/statements/function/index.html') 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 4d8e036a2e..be8920fca8 100644 --- a/files/zh-cn/web/javascript/reference/statements/function/index.html +++ b/files/zh-cn/web/javascript/reference/statements/function/index.html @@ -49,7 +49,7 @@ translation_of: Web/JavaScript/Reference/Statements/function

默认情况下,函数是返回 undefined 的。想要返回一个其他的值,函数必须通过一个 return 语句指定返回值。

-

有条件的创建函数

+

有条件的创建函数

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

@@ -96,7 +96,7 @@ if (true) {

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

-
hoisted(); // logs "foo"
+
hoisted(); // logs "foo"
 
 function hoisted() {
   console.log('foo');
@@ -107,7 +107,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');
@@ -120,11 +120,11 @@ 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;
 }
-

规范

+

规范

@@ -151,13 +151,13 @@ var notHoisted = function() {
-

浏览器兼容性

+

浏览器兼容性

{{Compat("javascript.statements.function")}}

-

相关链接

+

相关链接

  • {{jsxref("Functions_and_function_scope", "Functions and function scope")}}
  • -- cgit v1.2.3-54-g00ecf