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 --- .../reference/global_objects/function/apply/index.html | 12 ++++++------ .../reference/global_objects/function/bind/index.html | 2 +- .../reference/global_objects/function/call/index.html | 6 +++--- .../reference/global_objects/function/name/index.html | 2 +- .../reference/global_objects/function/tostring/index.html | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/function') diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html index 944791e29c..89706614c4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html @@ -38,7 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply

在调用一个存在的函数时,你可以为其指定一个 this 对象。 this 指当前对象,也就是正在调用这个函数的对象。 使用 apply, 你可以只写一次这个方法然后在另一个对象中继承它,而不用在新对象中重复写该方法。

-

apply 与 {{jsxref("Function.call", "call()")}} 非常相似,不同之处在于提供参数的方式。apply 使用参数数组而不是一组参数列表。apply 可以使用数组字面量(array literal),如 fun.apply(this, ['eat', 'bananas']),或数组对象, 如  fun.apply(this, new Array('eat', 'bananas'))

+

apply 与 {{jsxref("Function.call", "call()")}} 非常相似,不同之处在于提供参数的方式。apply 使用参数数组而不是一组参数列表。apply 可以使用数组字面量(array literal),如 fun.apply(this, ['eat', 'bananas']),或数组对象, 如  fun.apply(this, new Array('eat', 'bananas'))

你也可以使用 {{jsxref("Functions/arguments", "arguments")}}对象作为 argsArray 参数。 arguments 是一个函数的局部变量。 它可以被用作被调用对象的所有未指定的参数。 这样,你在使用apply函数的时候就不需要知道被调用对象的所有参数。 你可以使用arguments来把所有的参数传递给被调用对象。 被调用对象接下来就负责处理这些参数。

@@ -131,7 +131,7 @@ var min = minOfArray([5, 6, 2, 3, 7]);

使用闭包:

-
Function.prototype.construct = function(aArgs) {
+
Function.prototype.construct = function(aArgs) {
   var fConstructor = this, fNewConstr = function() {
     fConstructor.apply(this, aArgs);
   };
@@ -139,7 +139,7 @@ var min = minOfArray([5, 6, 2, 3, 7]);
   return new fNewConstr();
 };
-

使用 Function 构造器:

+

使用 Function 构造器:

Function.prototype.construct = function (aArgs) {
   var fNewConstr = new Function("");
@@ -168,7 +168,7 @@ console.log(myInstance.constructor);              // logs "MyConstructor"
 
 
注意: 这个非native的Function.construct方法无法和一些native构造器(例如Date)一起使用。 在这种情况下你必须使用Function.bind方法(例如,想象有如下一个数组要用在Date构造器中: [2012, 11, 4];这时你需要这样写: new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))() – -无论如何这不是最好的实现方式并且也许不该用在任何生产环境中).
-

规范

+

规范

@@ -200,11 +200,11 @@ console.log(myInstance.constructor);              // logs "MyConstructor"
-

浏览器兼容性

+

浏览器兼容性

{{Compat("javascript.builtins.Function.apply")}}

-

相关链接

+

相关链接

  • {{jsxref("Functions_and_function_scope/arguments", "arguments ")}} object
  • diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html index 8940da5ad4..45ee18de46 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html @@ -212,7 +212,7 @@ var slice = Function.prototype.apply.bind(unboundSlice); slice(arguments);
-

规范

+

规范

diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html index 5b9fc87b48..5962c181a0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html @@ -101,7 +101,7 @@ var obj = { greet.call(obj); // cats typically sleep between 12 and 16 hours -

使用 call 方法调用函数并且不指定第一个参数(argument

+

使用 call 方法调用函数并且不指定第一个参数(argument

在下面的例子中,我们调用了 display 方法,但并没有传递它的第一个参数。如果没有传递第一个参数,this 的值将会被绑定为全局对象。

@@ -127,7 +127,7 @@ function display() { display.call(); // Cannot read the property of 'sData' of undefined -

规范

+

规范

@@ -165,7 +165,7 @@ display.call(); // Cannot read the property of 'sData' of undefined

{{Compat("javascript.builtins.Function.call")}}

-

相关链接

+

相关链接

-

规范

+

规范

-- cgit v1.2.3-54-g00ecf