aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/functions/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/functions/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/functions/index.html24
1 files changed, 11 insertions, 13 deletions
diff --git a/files/zh-cn/web/javascript/reference/functions/index.html b/files/zh-cn/web/javascript/reference/functions/index.html
index 876a0c42ee..a1b4dcd965 100644
--- a/files/zh-cn/web/javascript/reference/functions/index.html
+++ b/files/zh-cn/web/javascript/reference/functions/index.html
@@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Functions
<p>调用函数时,传递给函数的值被称为函数的实参(值传递),对应位置的函数参数名叫作形参。如果实参是一个包含原始值(数字,字符串,布尔值)的变量,则就算函数在内部改变了对应形参的值,返回后,该实参变量的值也不会改变。如果实参是一个对象引用,则对应形参会和该实参指向同一个对象。假如函数在内部改变了对应形参的值,返回后,实参指向的对象的值也会改变:</p>
-<pre class="brush: js line-numbers language-js"> /* 定义函数 myFunc */
+<pre class="brush: js"> /* 定义函数 myFunc */
function myFunc(theObject)
{
//实参 mycar 和形参 theObject 指向同一个对象.
@@ -165,7 +165,7 @@ translation_of: Web/JavaScript/Reference/Functions
<h3 id="Function构造函数"> <code>Function</code>构造函数</h3>
<div class="note">
-<p><strong>注意:</strong> 不推荐使用 <code>Function</code> 构造函数创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。</p>
+<p><strong>备注:</strong> 不推荐使用 <code>Function</code> 构造函数创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。</p>
</div>
<p>所有其他对象, {{jsxref("Function")}} 对象可以用new操作符创建:</p>
@@ -184,11 +184,11 @@ translation_of: Web/JavaScript/Reference/Functions
<h3 id="生成器函数的构造函数">生成器函数的构造函数</h3>
<div class="note">
-<p><strong>注意:</strong> <code>GeneratorFunction</code> 不是一个全局对象,但可以从构造函数实例取得。(详情请查阅<a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/生成器函数">生成器函数</a>).</p>
+<p><strong>备注:</strong> <code>GeneratorFunction</code> 不是一个全局对象,但可以从构造函数实例取得。(详情请查阅<a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/生成器函数">生成器函数</a>).</p>
</div>
<div class="note">
-<p><strong>注意:</strong> 不推荐使用构造器函数的构造函数 (<code>GeneratorFunction</code> constructor)创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。</p>
+<p><strong>备注:</strong> 不推荐使用构造器函数的构造函数 (<code>GeneratorFunction</code> constructor)创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。</p>
</div>
<p>所有其他对象, {{jsxref("GeneratorFunction")}} 对象可以用 new 操作符创建:</p>
@@ -244,7 +244,7 @@ translation_of: Web/JavaScript/Reference/Functions
<p>从ECMAScript 6开始, 你可以用更短的语法定义自己的方法,类似于getters和setters。详情请查阅 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions">method definitions</a> .</p>
-<pre class="brush: js line-numbers language-js"> var obj = {
+<pre class="brush: js"> var obj = {
foo() {},
bar() {}
};
@@ -267,7 +267,7 @@ translation_of: Web/JavaScript/Reference/Functions
<p>一个匿名函数的函数表达式,被赋值给变量<code>multiply</code>:</p>
-<pre class="brush: js line-numbers language-js"> var multiply = function(x, y) {
+<pre class="brush: js"> var multiply = function(x, y) {
return x * y;
};
</pre>
@@ -284,7 +284,7 @@ translation_of: Web/JavaScript/Reference/Functions
<p>函数名和函数的变量存在着差别。函数名不能被改变,但函数的变量却能够被再分配。函数名只能在函数体内使用。倘若在函数体外使用函数名将会导致错误(如果函数之前是通过一个var语句声明的则是undefined)。例如:</p>
-<pre class="brush: js line-numbers language-js">var y = function x() {};
+<pre class="brush: js">var y = function x() {};
alert(x); // throws an error
</pre>
@@ -296,12 +296,12 @@ alert(x); // throws an error
<p>使用用 '<code>new Function'定义的函数没有函数名。</code> 然而,在 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> JavaScript引擎中,其函数的序列化形式表现的好像它拥有一个名叫"anonymous"的名称一样。比如,使用 <code>alert(new Function())</code> 输出:</p>
-<pre class="brush: js line-numbers language-js">function anonymous() {
+<pre class="brush: js">function anonymous() {
}</pre>
<p>而实际上其函数并没有名称,<code>anonymous</code> 不是一个可以在函数内被访问到的变量。例如,下面的例子将会导致错误:</p>
-<pre class="brush: js line-numbers language-js">var foo = new Function("alert(anonymous);");
+<pre class="brush: js">var foo = new Function("alert(anonymous);");
foo();
</pre>
@@ -345,7 +345,7 @@ function foo() { // source element
<h3 id="例子">例子</h3>
-<pre class="brush: js line-numbers language-js">// 函数声明
+<pre class="brush: js">// 函数声明
function foo() {}
// 函数表达式
@@ -486,9 +486,7 @@ result = padZeros(5,4); // returns "0005"</pre>
<h2 id="浏览器兼容">浏览器兼容</h2>
-
-
-<p>{{Compat("javascript.functions")}}</p>
+{{Compat}}
<h2 id="参阅">参阅</h2>