From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- .../ecmascript_7_support_in_mozilla/index.html | 82 ------ .../javascript/new_in_javascript/1.1/index.html | 71 ------ .../javascript/new_in_javascript/1.2/index.html | 89 ------- .../javascript/new_in_javascript/1.3/index.html | 138 ---------- .../javascript/new_in_javascript/1.4/index.html | 25 -- .../javascript/new_in_javascript/1.5/index.html | 42 --- .../javascript/new_in_javascript/1.6/index.html | 35 --- .../javascript/new_in_javascript/1.7/index.html | 40 --- .../javascript/new_in_javascript/1.8.1/index.html | 29 --- .../javascript/new_in_javascript/1.8.5/index.html | 122 --------- .../javascript/new_in_javascript/1.8/index.html | 39 --- .../ecmascript_5_support_in_mozilla/index.html | 41 --- .../ecmascript_6_support_in_mozilla/index.html | 282 --------------------- .../web/javascript/new_in_javascript/index.html | 99 -------- .../functions/arguments/caller/index.html | 47 ---- .../global_objects/array/observe/index.html | 92 ------- .../global_objects/array/unobserve/index.html | 86 ------- .../global_objects/arraybuffer/transfer/index.html | 116 --------- .../global_objects/date/tolocaleformat/index.html | 73 ------ .../global_objects/function/arity/index.html | 16 -- .../global_objects/function/isgenerator/index.html | 40 --- .../reference/global_objects/iterator/index.html | 188 -------------- .../global_objects/number/tointeger/index.html | 97 ------- .../global_objects/object/count/index.html | 88 ------- .../global_objects/object/eval/index.html | 85 ------- .../global_objects/object/getnotifier/index.html | 93 ------- .../global_objects/object/nosuchmethod/index.html | 208 --------------- .../global_objects/object/observe/index.html | 160 ------------ .../global_objects/object/parent/index.html | 43 ---- .../global_objects/object/unobserve/index.html | 133 ---------- .../global_objects/object/unwatch/index.html | 105 -------- .../global_objects/object/watch/index.html | 201 --------------- .../global_objects/parallelarray/index.html | 53 ---- .../global_objects/string/quote/index.html | 116 --------- .../operators/array_comprehensions/index.html | 157 ------------ .../operators/expression_closures/index.html | 76 ------ .../operators/generator_comprehensions/index.html | 193 -------------- .../reference/statements/for_each...in/index.html | 69 ----- 38 files changed, 3669 deletions(-) delete mode 100644 files/zh-cn/web/javascript/ecmascript_7_support_in_mozilla/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.1/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.2/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.3/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.4/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.5/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.6/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.7/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.8.1/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.8.5/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/1.8/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/ecmascript_5_support_in_mozilla/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/ecmascript_6_support_in_mozilla/index.html delete mode 100644 files/zh-cn/web/javascript/new_in_javascript/index.html delete mode 100644 files/zh-cn/web/javascript/reference/functions/arguments/caller/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/array/observe/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/array/unobserve/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/arraybuffer/transfer/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/date/tolocaleformat/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/function/arity/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/function/isgenerator/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/iterator/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/number/tointeger/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/count/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/eval/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/getnotifier/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/nosuchmethod/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/observe/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/parent/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/unobserve/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/unwatch/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/object/watch/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/parallelarray/index.html delete mode 100644 files/zh-cn/web/javascript/reference/global_objects/string/quote/index.html delete mode 100644 files/zh-cn/web/javascript/reference/operators/array_comprehensions/index.html delete mode 100644 files/zh-cn/web/javascript/reference/operators/expression_closures/index.html delete mode 100644 files/zh-cn/web/javascript/reference/operators/generator_comprehensions/index.html delete mode 100644 files/zh-cn/web/javascript/reference/statements/for_each...in/index.html (limited to 'files/zh-cn/web/javascript') diff --git a/files/zh-cn/web/javascript/ecmascript_7_support_in_mozilla/index.html b/files/zh-cn/web/javascript/ecmascript_7_support_in_mozilla/index.html deleted file mode 100644 index 55732f87ad..0000000000 --- a/files/zh-cn/web/javascript/ecmascript_7_support_in_mozilla/index.html +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Mozilla对下一代ECMAScript 的支持 -slug: Web/JavaScript/ECMAScript_7_support_in_Mozilla -tags: - - ECMAScript 2015 - - ECMAScript 2016 - - ECMAScript 2017 - - ECMAScript 2018 - - new features -translation_of: Archive/Web/JavaScript/ECMAScript_Next_support_in_Mozilla ---- -
{{jsSidebar("New_in_JS")}}
- -

下一代 ECMAScript 是指在 ECMAScript 2015 被推出后的 ECMA-262 标准(通常被称为 JavaScript)的新特性。新版本的 ECMAScript 规范会每年发布。

- -

你可以在 tc39/ecma262 这个仓库中看见当前的规范草案。

- -

es-discuss 是一个关于 ECMAScript 标准有关反馈的渠道。

- -

ECMAScript 2016

- -

下面的 ECMAScript 2016 特性已实现:

- -

 

- - - -

ECMAScript 2017

- -

下面的 ECMAScript 2017 特性已实现:

- -

 

- - - -

实验性的新特性

- -

以下特性已经实现,但可能仅在 Firefox Nightly 中可用、或者需要浏览器 flags 开启;且此提案的标准可能尚未正式进入 ECMAScript 规范,请小心使用。

- -

ArrayBuffer 对象的新方法

- - - -

新的 TypedObject 对象

- - - -

新的 Shared Memory 对象

- - - -

相关链接

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.1/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.1/index.html deleted file mode 100644 index 968f518145..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.1/index.html +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: JavaScript 1.1的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.1 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.1 ---- -
{{jsSidebar("New_in_JS")}}
- -

下面介绍的是JavaScript从Netscape Navigator 2.0到3.0的更新日志。旧的Netscape文档请参考"第1版之后新增的特性"。Netscape Navigator 3.0在1996年8月19发布,是支持JavaScript的浏览器的第二个主要的版本。

- -

JavaScript 版本

- -

Netscape Navigator 3.0 也引进了JavaScript语言的版本号。

- -
<SCRIPT LANGUAGE="JavaScript">    <!-- JavaScript for Navigator 2.0. -->
-<SCRIPT LANGUAGE="JavaScript1.1"> <!-- JavaScript for Navigator 3.0. -->
- -

JavaScript 1.1 新特性

- -

新增的对象

- - - -

新增的属性

- - - -

新增的方法

- - - -

新增的操作符

- - - -

其他新特性

- - - -

JavaScript 1.1修改的功能

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.2/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.2/index.html deleted file mode 100644 index 17fde7ba38..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.2/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: JavaScript 1.2的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.2 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.2 ---- -
{{jsSidebar("New_in_JS")}}
- -

下面介绍的是JavaScript从Netscape Navigator 3.0到4.0的更新日志。旧的Netscape文档可以在archive.org上面找到。Netscape Navigator 4.0在1997年6月11日发布,它是是支持JavaScript的浏览器的第三个主要的版本。

- -

JavaScript 版本

- -

Netscape Navigator 4.0将JavaScript语言的版本升到1.2。需要注意的是,Netscape Navigator 3.0以及更早的版本忽略了设置为"JavaScript 1.2"和更高的版本的脚本语言属性。

- -
<SCRIPT LANGUAGE="JavaScript1.1"> <!-- JavaScript for Navigator 3.0. -->
-<SCRIPT LANGUAGE="JavaScript1.2"> <!-- JavaScript for Navigator 4.0. -->
- -

JavaScript 1.2新特性

- -

新增的对象

- - - -

新增的属性

- - - -

新增的方法

- - - -

新增的操作符

- - - -

新增的语句

- - - -

其他新特性

- - - -

JavaScript 1.2修改的功能

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.3/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.3/index.html deleted file mode 100644 index 193d5156d8..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.3/index.html +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: JavaScript 1.3的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.3 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.3 ---- -
{{jsSidebar("New_in_JS")}}
- -

下面介绍的是JavaScript从Netscape Navigator 4.0到4.5的更新日志。旧的Netscape文档可以在archive.org上面找到。Netscape Navigator 4.5是在1998年10月19日发布的。

- -

JavaScript 1.3 最显著的变化是通过消除JavaScript1.2和1997年6月发布的新ECMA标准的不一致性来遵守ECMA-262和Unicode。JavaScript 1.2附加的特性,在ECMA-262的规定外还保留在JavaScript语言(见下面的列表中的差异)。

- -

JavaScript 版本

- -

Netscape Navigator 4.06 到 4.5 将JavaScript语言的版本升到1.3。需要注意的是,Netscape Navigator 4.0 到 4.05以及更早的版本忽略了设置为"JavaScript 1.3"和更高的版本的脚本语言属性。

- -
<SCRIPT LANGUAGE="JavaScript1.2"> <!-- JavaScript for Navigator 4.0. -->
-<SCRIPT LANGUAGE="JavaScript1.3"> <!-- JavaScript for Navigator 4.5. -->
- -

JavaScript 1.3新特性

- -

新增的全局变量

- - - -

新增的方法

- - - -

其他新特性

- - - -

JavaScript 1.3 修改的功能

- - - -

非ECMA-262规范的JavaScript 1.3特性

- -

下面是关于1998年6月的ECMA-262版本和JavaScript 1.3之间的比较。下面的特性不是当时的标准的一部分,但是在JavaScript 1.3里面实施了。

- -

关键字和操作符

- - - -

语句

- - - -

内置对象

- - - -

内置对象的方向

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.4/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.4/index.html deleted file mode 100644 index a76c4f5424..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.4/index.html +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: JavaScript 1.4的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.4 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.4 ---- -
{{jsSidebar("New_in_JS")}}
- -

下面是 JavaScript 1.4 的更新记录,它只可用于 1999 年发布的 Netscape 服务端 JavaScript。 旧的 Netscape 文档可在 archive.org 找到。

- -

JavaScript 1.4的新特性

- - - -

JavaScript 1.4的功能改动

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.5/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.5/index.html deleted file mode 100644 index 0375ad3f7f..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.5/index.html +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: JavaScript 1.5 的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.5 -tags: - - JavaScript - - 版本 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.5 ---- -
{{jsSidebar("New_in_JS")}}
- -

以下为JavaScript 1.5 的更新日志。该版本包含在发行于2000年11月14日的Netscape Navigator 6.0中,也在后续的的Netscape Navigator版本和Firefox 1.0中使用。你可以拿JavaScript 1.5 和JScript version 5.5,Internet Explorer 5.5进行比较,后者发行于2000年7月。相应的ECMA 标准是 ECMA-262 Edition 3版 (自1999年12月)。

- -

JavaScript 1.5 新特性

- - - -

JavaScript 1.5 功能变化

- - - -

 

diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.6/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.6/index.html deleted file mode 100644 index 928fd75334..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.6/index.html +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: JavaScript 1.6 的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.6 -tags: - - JavaScript - - 版本 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.6 ---- -
-
{{jsSidebar("New_in_JS")}}
- -

以下是JavaScript 1.6的更新日志。JavaScript 1.6已经被包含在2005年11月发布的Firefox 1.5 (Gecko 1.8)中。JavaScript 1.6相对应的ECMA标准是ECMA-262第3版和ECMAScript for XML (E4X),这让它拥有了一些额外的特性 。引入了一些新特性:E4X,几个新的数组方法,还数组字符串的通用接口(generics)

- -

JavaScript 1.6新特性

- - - -

JavaScript 1.6功能变化

- - -
diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.7/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.7/index.html deleted file mode 100644 index e268345ca5..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.7/index.html +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: JavaScript 1.7 的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.7 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.7 ---- -
{{jsSidebar("New_in_JS")}}
- -
 
- -
以下是javaScript 1.7版本的更新日志,这个版本被包括在 Firefox 2 (2006年10月)。
- -

 

- -

JavaScript 1.7是一个引出了一些新特性的语言更新,尤其是generator,iterator,数组推导式, let 表达式和解构赋值。

- -

使用 JavaScript 1.7

- -

为了使用 JavaScript 1.7的一些新特性,你需要明确指出你希望使用 JavaScript 1.7。在HTML 或XUL code中,使用:

- -
<script type="application/javascript;version=1.7"></script>
-
- -

当使用 JavaScript shell的时候,你需要用 -version 170 开启命令行或者用version() 函数来设置你想使用的JavaScript版本。

- -
version(170);
-
- -

你需要指定1.7版本来使用新的“yield”和“let”关键字,因为现存的代码可能用它们当变量或者函数名用。没有涉及到新关键词的特性(比如解构赋值和数组推导式)可以直接使用,而不需要指明JavaScript版本。

- -

JavaScript 1.7的新特性

- -

以下JavaScript 1.7的新特性目前还不是ECMA-262标准的一部分。在最近的Firefox版本中会根据ECMAScipt6中的描述来实现这些功能。具体内容见这些参考页面。

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.8.1/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.8.1/index.html deleted file mode 100644 index 9ca99c06af..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.8.1/index.html +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: JavaScript 1.8.1 的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.8.1 -tags: - - Firefox 3.5 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.8.1 ---- -
{{jsSidebar("New_in_JS")}}
- -

下面是JavaScript 1.8.1 的更新内容. 该版本已包含在 Firefox 3.5 中.

- -

JavaScript 1.8.1 是在语义上有适度更新的版本; 其主要更新是添加能够提升性能的Tracemonkey即时编译器

- -

JavaScript 1.8.1 新特性

- - - -

JavaScript 1.8.1 功能更新

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.8.5/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.8.5/index.html deleted file mode 100644 index a61a892e70..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.8.5/index.html +++ /dev/null @@ -1,122 +0,0 @@ ---- -title: JavaScript 1.8.5 的新特性 -slug: Web/JavaScript/New_in_JavaScript/1.8.5 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.8.5 ---- -
{{jsSidebar("New_in_JS")}}
- -

下面的内容是JavaScript 1.8.5的更新记录. 该版本已包含在Firefox 4中.

- -

JavaScript 1.8.5的新特性

- -

新函数

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionDescription
Object.create()使用指定的原型对象和属性. {{bug("492840")}}
Object.defineProperty()为对象添加给定的描述信息的属性名.
Object.defineProperties()为对象添加多个给定的描述信息的属性名.
Object.getOwnPropertyDescriptor()返回对象的指定属性名的描述信息. {{bug("505587")}}
Object.keys()返回由对象的所有可枚举属性组成的数组. {{bug("307791")}}
Object.getOwnPropertyNames()返回由对象的所有可枚举和不可枚举属性组成的数组. {{bug("518663")}}
Object.preventExtensions()防止对象进行任意的扩展. {{bug("492849")}}
Object.isExtensible()判断对象是否可以扩展. {{bug("492849")}}
Object.seal()防止其他代码删除对象的属性. {{bug("492845")}}
Object.isSealed()判断对象是否是密封(即禁止删除属性)的. {{bug("492845")}}
Object.freeze()冻结一个对象: 其他代码不能删除或修改任何属性. {{bug("492844")}}
Object.isFrozen()判断对象是否是冻结的. {{bug("492844")}}
Array.isArray()判断变量是否是数组. {{bug("510537")}}
Date.prototype.toJSON()返回一个Date对象用JSON格式化的字符串.
Function.prototype.bind()创建一个新函数,当这个函数被调用时,函数会使用提供的上下文环境(给定的字符序列) {{bug("429507")}}
- -

ECMAScript5新特性

- - - -

其他标准化的工作

- -

删除一些定义getters和setters的非标准化语法; ECMAScript 5 定义的语法没有变化. 这些语法很难懂且很少被使用; 如果这个影响到你, 详细内容请看 这篇博客.

- -

新对象

- - - - - - - - - - - - - - -
ObjectDescription
Proxy提供创建对象和函数的代理,以在Javascript中支持元编程.
- -

JavaScript 1.8.5中功能变化

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/1.8/index.html b/files/zh-cn/web/javascript/new_in_javascript/1.8/index.html deleted file mode 100644 index d69d021c25..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/1.8/index.html +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: New in JavaScript 1.8 -slug: Web/JavaScript/New_in_JavaScript/1.8 -tags: - - JavaScript - - 版本 -translation_of: Archive/Web/JavaScript/New_in_JavaScript/1.8 ---- -
{{jsSidebar("New_in_JS")}}
- -

以下为JavaScript 1.8的更新日志。JavaScript 1.8 是 Gecko 1.9(已合并在 Firefox 3 中)的一部分。参见 {{ Bug("380236") }} 以跟踪 JavaScript 1.8。

- -

使用 JavaScript 1.8

- -

为了可以在 HTML 中使用 JavaScript 1.8 的新特性,需要这样写:

- -
 <script type="application/javascript;version=1.8"> ... 你的代码 ... </script>
-
- -

另一种方法(不推荐)是使用旧式的 <script> 属性 language,把它定义为 "JavaScript1.8"。

- -

在使用 JavaScript shell 、JavaScript XPCOM 组件,或者 XUL <script> 元素的时候,将自动启用最新的JS版本(Mozilla 1.9中的 JS1.8)({{ Bug("381031") }}, {{ Bug("385159") }})。

- -

如果需要使用新的关键字 "yield" 和 "let",你需要指定是1.7版本或者更高的版本,因为现有的代码可能会把这两个关键字用作变量名或者函数名。如果要使用的新特性没有引入任何新的关键字(例如生成器表达式),就可以不指定 JavaScript 的版本。

- -

JavaScript 1.8新特性

- - - -

JavaScript 1.8功能更新

- -

对for..in解构的修改

- -

JavaScript1.8中的一个修改是对JavaScript1.7中引入的数组键值结构相关的bug修复。之前可以用for ( var [key, value] in array )的方式来解构一个数组的键值。但是,这也让对数组的数组的键值解构变得不可能(比如一个迭代器返回一个当前键值对的数组)。现在这个问题可以用for ( var [key, value] in Iterator(array))来解决({{ Bug("366941") }})。

diff --git a/files/zh-cn/web/javascript/new_in_javascript/ecmascript_5_support_in_mozilla/index.html b/files/zh-cn/web/javascript/new_in_javascript/ecmascript_5_support_in_mozilla/index.html deleted file mode 100644 index 2dc69205cb..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/ecmascript_5_support_in_mozilla/index.html +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: ECMAScript 5 support in Mozilla -slug: Web/JavaScript/New_in_JavaScript/ECMAScript_5_support_in_Mozilla -translation_of: Archive/Web/JavaScript/New_in_JavaScript/ECMAScript_5_support_in_Mozilla ---- -
{{jsSidebar("New_in_JS")}}
- -

ECMAScript 5.1, an older version of the standard upon which JavaScript is based, was approved in June 2011.

- -

The JavaScript runtime used in the latest versions of Mozilla projects including both Firefox and Thunderbird has full support for ECMAScript 5.1 features. This article covers the features supported by different versions of Mozilla's JavaScript runtime.

- -

Supported features

- -

Added in JavaScript 1.8.5 (Gecko 2, Firefox 4 and later)

- -

Firefox 4 has full ECMAScript 5 support including the Object.* methods and strict mode. See New in JavaScript 1.8.5.

- -

Added in JavaScript 1.8.1 (Gecko 1.9.1, Firefox 3.5)

- - - -

Improvements laid out by ECMAScript 5 have been made in the parsing algorithm that prevents evaluating XHTML as JavaScript code in certain circumstances.

- -

Added in JavaScript 1.6 (Gecko 1.8, Firefox 1.5)

- -

New Array methods offering several improved methods for manipulating arrays -- have been part of JavaScript since JavaScript 1.6. Now they've been standardized as part of ECMAScript 5.

- -

See also

- - diff --git a/files/zh-cn/web/javascript/new_in_javascript/ecmascript_6_support_in_mozilla/index.html b/files/zh-cn/web/javascript/new_in_javascript/ecmascript_6_support_in_mozilla/index.html deleted file mode 100644 index 25210c32b2..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/ecmascript_6_support_in_mozilla/index.html +++ /dev/null @@ -1,282 +0,0 @@ ---- -title: Mozilla 对 ECMAScript 6 的支持 -slug: Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla -tags: - - ECMAScript2015 - - ECMAScript6 - - Firefox - - JavaScript -translation_of: Archive/Web/JavaScript/New_in_JavaScript/ECMAScript_2015_support_in_Mozilla ---- -
-
{{jsSidebar("New_in_JS")}}
- -

ECMAScript 2015 (6th Edition)是目前 ECMAScript 语言规范的标准。通常被称为"ES2015",在SpiderMonkey 中它规定了 JavaScript 的实现标准,SpiderMonkey 是一个 JavaScript 引擎,被广泛用于火狐浏览器等谋智的众多产品中。

- -

"ES.next" 的第一份工作草案 (基于 ECMAScript 5.1) 发布于 2011 年 7 月 12 日,代号为 "ES.next" 或 "Harmony"。2014 年 8 月,ECMAScript 2015 草案规范停止增加新的功能,开始进入稳定期与 bug 修复阶段。最终,ECMA-262 Edition 6 于 2015 年 6 月 17 日由 ECMA 联合大会 (ECMA General Assembly) 作为标准正式发布。它同时也是国际工业标准 ISO/IEC 16262:2016。

- -

你可以通过 ecma-international.org 免费下载规范的 PDFHTML 版本。

- -

es-discuss 是 ECMAScript 规范的讨论与反馈渠道。

- -

Firefox 已经支持的特性

- -

这里列出的功能已经在 Firefox 中支持;每个特性后面标注了具体实现的浏览器版本。

- -

标准库

- -

Array 对象的补充

- - - -

新的 Map 和 Set,以及 WeakMap 和 WeakSet 对象

- - - -

新的 Math 方法

- - - -

Number 对象的补充

- - - -

Object 对象的补充

- - - -

Date 对象的补充

- - - -

新的 Promise 对象

- - - -

新的 Reflect 对象

- - - -

RegExp 对象的补充

- - - -

String 对象的补充

- - - -

新的 Symbol 对象

- - - -

Typed Arrays

- -

Typed arrays 已经合并到 ECMAScript 2015 中,不再具有自己单独的规范

- - - -

表达式和操作符

- - - - - -

语句

- - - -

函数

- - - -

其他特性

- - - -

和 ES2015 规范不兼容的特性

- -

Firefox (部分)实现了以下特性,但是与规范不兼容。原因有如下几个:Firefox 是依据 ES 6 规范的早期草案来实现,或者 Firefox 是作为实验性特性来实现,而当时与之类似的特性还没有被添加到 ES2015 规范中。

- - - -

相关链接

- - -
diff --git a/files/zh-cn/web/javascript/new_in_javascript/index.html b/files/zh-cn/web/javascript/new_in_javascript/index.html deleted file mode 100644 index 95eee26559..0000000000 --- a/files/zh-cn/web/javascript/new_in_javascript/index.html +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: JavaScript更新 -slug: Web/JavaScript/New_in_JavaScript -tags: - - ECMAScript - - ECMAScript 2017 - - JavaScript - - 版本 -translation_of: Archive/Web/JavaScript/New_in_JavaScript ---- -
{{jsSidebar("New_in_JS")}}
- -
 
- -

本章包含有关JavaScript版本历史记录的信息,以及基于Mozilla/SpiderMonkey-的JavaScript应用程序的实现状态,例如Firefox。

- -

ECMAScript版本

- -
-
语言资源
-
在这里学习更多的JavaScript的标准ECMAScript。
-
ECMAScript 5的支持情况
-
Mozilla 的引擎和产品 对于标准ECMA-262 Edition 5.1的支持情况。
-
ECMAScript 2015的支持情况
-
Mozilla 的引擎和产品对于标准ECMA-262 Edition 6的支持情况。
-
ECMAScript 2016的支持情况
-
Mozilla 的引擎和产品对于即将到来的ECMA-262 Edition 7的支持情况.
-
- -

JavaScript发布说明

- -
-
Firefox中的JavaScript更新日志
-
Firefox 5以及以后版本的JavaScript日志更新情况。
-
Chrome中的JavaScript更新日志
-
Chrome中的JavaScript日志更新情况。
-
- -

JavaScript版本

- -

弃用项 ({{deprecated_inline()}})。这里面是一些已经确定的弃用的api以及一下Mozilla组织专用的API  正在被慢慢的弃用不建议使用。Firefox 4 所用的javascirpt引擎是 ECMAScript(1.8.5). 就像现在我们提到的新的引擎 ECMA-262 里面的标准都在 ECMAScript 2015 里面的实现了API。

- -

JavaScript于1996年3月在Netscape Navigator 2.0和Internet Explorer 2.0中发布为1.0版。

- -
-
JavaScript 1.1
-
该版本在Netscape Navigator 3.0中使用。发布于1996年8月19日。
-
JavaScript 1.2
-
该版本在Netscape Navigator 4.0-4.05中使用。发布于1997年6月11日。
-
JavaScript 1.3
-
该版本在Netscape Navigator 4.06-4.7x中使用。发布于1998年10月19日。符合ECMA-262第1版和第2版的标准
-
JavaScript 1.4
-
版本在Netscape的服务器端发送的JavaScript。于1999年发行。
-
JavaScript 1.5
-
该版本在Netscape Navigator 6.0和Firefox 1.0中使用。发布于2000年11月14日。符合ECMA-262第3版的标准
-
JavaScript 1.6
-
该版本在 Firefox 1.5中使用。发布于2005年11月。加入了ECMAScript标准的XML(E4X),Array方法,String以及泛型
-
JavaScript 1.7
-
Version shipped in Firefox 2. Released in October 2006.
- Includes generators, iterators, array comprehensions, let expressions, and destructuring assignment.
-
JavaScript 1.8
-
Version shipped in Firefox 3. Released in June 2008.
-
包括表达式闭包,生成器表达式和Array.reduce()
-
JavaScript 1.8.1
-
Version shipped in Firefox 3.5. Released on June 30, 2009.
-
包括TraceMonkey JIT并原生支持JSON。
-
JavaScript 1.8.2
-
Version shipped in Firefox 3.6. Released June 22, 2009.
- Includes only minor changes.
-
JavaScript 1.8.5
-
Version shipped in Firefox 4. Released July 27, 2010.包括符合ECMA-262 Edition 5的许多新功能。 这是最后一个JavaScript版本。
-
ES2015
-
- - - -

ES2016

- - - -

ES2017

- - - -

 

- -

 

diff --git a/files/zh-cn/web/javascript/reference/functions/arguments/caller/index.html b/files/zh-cn/web/javascript/reference/functions/arguments/caller/index.html deleted file mode 100644 index 13128ec962..0000000000 --- a/files/zh-cn/web/javascript/reference/functions/arguments/caller/index.html +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: caller -slug: Web/JavaScript/Reference/Functions/arguments/caller -translation_of: Archive/Web/JavaScript/arguments.caller ---- -

{{jsSidebar("Functions")}}

- -

废弃的 arguments.caller 属性原先用在函数执行的时候调用自身。本属性已被移除且不再有用。

- -

描述

- -

arguments.caller 已经不可使用了,但是你还可以使用 {{jsxref("Function.caller")}}。

- -
function whoCalled() {
-   if (whoCalled.caller == null)
-      console.log('I was called from the global scope.');
-   else
-      console.log(whoCalled.caller + ' called me!');
-}
-
- -

示例

- -

下例演示了arguments.caller属性的作用.

- -
function whoCalled() {
-   if (arguments.caller == null)
-      console.log('该函数在全局作用域内被调用.');
-   else
-      console.log(arguments.caller + '调用了我!');
-}
- -

规范

- -

无相关标准。JavaScript 1.1 实现,{{bug(7224)}} 移除 caller,因为潜在的不安全性。

- -

浏览器支持

- - - -

{{Compat("javascript.functions.arguments.caller")}}

- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/observe/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/observe/index.html deleted file mode 100644 index 7c2dcc8474..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/array/observe/index.html +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: Array.observe() -slug: Web/JavaScript/Reference/Global_Objects/Array/observe -tags: - - JavaScript - - 实验性 - - 数组 - - 方法 - - 过时的 -translation_of: Archive/Web/JavaScript/Array.observe ---- -
{{JSRef}}{{obsolete_header}}
- -

Array.observe() 方法用于异步监视数组发生的变化,类似于针对对象的 {{jsxref("Object.observe()")}} 。当数组的值发生变化时,它按发生顺序提供了一个变化流。与 Object.observe() 类似,它由如下可接受的变化类型列表["add"、"update"、"delete"、"splice"]触发。

- -

语法

- -
Array.observe(arr, callback)
- -

参数

- -
-
arr
-
用于被监视的数组
-
callback
-
每当数组发生变化时,使用如下参数调用该函数: -
-
changes
-
用于表示变化的对象数组。每个变化对象的属性如下: -
    -
  • name: 变化的属性名。
  • -
  • object: 变化后的数组。
  • -
  • type: 用于表示变化类型的字符串。其取值为"add"、"update"、"delete""splice"之一。
  • -
  • oldValue: 仅用于"update""delete"类型。变化之前的取值。
  • -
  • index: 仅用于"splice"类型。变化发生所在索引。
  • -
  • removed: 仅用于"splice"类型。被删除元素组成的数组。
  • -
  • addedCount: 仅用于"splice"类型。被添加的元素数量。
  • -
-
-
-
-
- -

描述

- -

每次 arr 发生任何变化时,回调函数将被调用,调用参数为所有变化按发生顺序组成的数组。

- -
-

通过Array方法如 Array.prototype.pop( ) 触发的变化将被报告成"splice"变化,长度不变但索引赋值发生变化的将被报告成"update"变化。

-
- -

示例

- -

Example: Logging different change types

- -
var arr = ['a', 'b', 'c'];
-
-Array.observe(arr, function(changes) {
-  console.log(changes);
-});
-
-arr[1] = 'B';
-// [{type: 'update', object: <arr>, name: '1', oldValue: 'b'}]
-
-arr[3] = 'd';
-// [{type: 'splice', object: <arr>, index: 3, removed: [], addedCount: 1}]
-
-arr.splice(1, 2, 'beta', 'gamma', 'delta');
-// [{type: 'splice', object: <arr>, index: 1, removed: ['B', 'c'], addedCount: 3}]
-
- -

标准规范

- -

Strawman proposal specification.

- -

浏览器支持

- -
-
- - -

{{Compat("javascript.builtins.Array.observe")}}

-
-
- -

相关内容

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/unobserve/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/unobserve/index.html deleted file mode 100644 index 90678a1081..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/array/unobserve/index.html +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: Array.unobserve() -slug: Web/JavaScript/Reference/Global_Objects/Array/unobserve -translation_of: Archive/Web/JavaScript/Array.unobserve ---- -
{{JSRef}} {{non-standard_header}}
- -

Array.unobserve()方法用来移除{{jsxref("Array.observe()")}}设置的所有观察者。

- -

语法

- -
Array.unobserve(arr, callback)
- -

参数

- -
-
arr
-
停止观察的数组。
-
 
-
callback回调
-
需要停止的array arr每次改变都会调用的函数引用。
-
- -

描述

- -

Array.unobserve() 方法因为要移除观察者,所以应该在{{jsxref("Array.observe()")}}调用后调用。

- -

回调函数应该是一个函数的引用并且不能是匿名函数, 因为这个函数需要用来移除前面的观察者, 如果用匿名函数是没有用的,将不能移除任何观察者。

- -

例子

- -

停止观察一个数组

- -
var arr = [1, 2, 3];
-
-var observer = function(changes) {
-  console.log(changes);
-}
-
-Array.observe(arr, observer);
-​
-arr.push(4);
-// [{type: "splice", object: <arr>, index: 3, removed:[], addedCount: 1}]
-
-Array.unobserve(arr, observer);
-
-arr.pop();
-// The callback wasn't called
- -

使用匿名函数

- -
var persons = ['Khalid', 'Ahmed', 'Mohammed'];
-
-Array.observe(persons, function (changes) {
-  console.log(changes);
-});
-
-persons.shift();
-// [{type: "splice", object: <arr>, index: 0, removed: [ "Khalid" ], addedCount: 0 }]
-
-Array.unobserve(persons, function (changes) {
-  console.log(changes);
-});
-
-persons.push('Abdullah');
-// [{type: "splice", object: <arr>, index: 2, removed: [], addedCount: 1 }]
-// The callback will always be called
-
- -

浏览器兼容性

- -
-
- - -

{{Compat("javascript.builtins.Array.unobserve")}}

-
-
- -

相关内容

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/arraybuffer/transfer/index.html b/files/zh-cn/web/javascript/reference/global_objects/arraybuffer/transfer/index.html deleted file mode 100644 index cf3185f637..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/arraybuffer/transfer/index.html +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: ArrayBuffer.transfer() -slug: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer -translation_of: Archive/Web/JavaScript/ArrayBuffer.transfer ---- -
{{JSRef}} {{SeeCompatTable}}
- -

 静态ArrayBuffer.transfer() 方法返回一个新的ArrayBuffer, 其内容取自oldBuffer的数据,并且根据 newByteLength 的大小来对数据进行截取或者以0扩展。 如果 newByteLength 未定义,则使用 oldBuffer 的byteLength。这个操作使得 oldBuffer 处于被移除的状态。

- -

语法

- -
ArrayBuffer.transfer(oldBuffer [, newByteLength]);
- -

参数

- -
-
oldBuffer
-
 要转移的{{jsxref("ArrayBuffer")}}对象。
-
newByteLength
-
ArrayBuffer 对象的字节长度。
-
- -

返回值

- -

一个新的ArrayBuffer对象。

- -

描述

- -

ArrayBuffer.transfer()方法允许你增长和移除 ArrayBuffer 对象。不需复制就能增长一个ArrayBuffer的功能,对于大的缓冲区来说,有速度优势 (类似realloc) 。当释放底层内存时,移除ArrayBuffer的功能给开发者提供了显式控制。这避免了必须丢弃所有引用和等待垃圾回收。

- -

示例

- -
var buf1 = new ArrayBuffer(40);
-new Int32Array(buf1)[0] = 42;
-
-var buf2 = ArrayBuffer.transfer(buf1, 80);
-buf1.byteLength; // 0 but if you use the polyfill then the value is still 40
-buf2.byteLength; // 80
-new Int32Array(buf2)[0]; // 42
-
-var buf3 = ArrayBuffer.transfer(buf2, 0);
-buf2.byteLength; // 0 but if you use the polyfill then the value is still 80
-buf3.byteLength; // 0
-
- -

Polyfill

- -

You can partially work around this by inserting the following code at the beginning of your scripts, allowing use of much of the functionality of transfer() in implementations that do not natively support it. This is not the exact equivalent of this API, but this function transfers data from one ArrayBuffer to another ArrayBuffer.

- -
if(!ArrayBuffer.transfer) {
-    ArrayBuffer.transfer = function (source, length) {
-        source = Object(source);
-        var dest = new ArrayBuffer(length);
-        if(!(source instanceof ArrayBuffer) || !(dest instanceof ArrayBuffer)) {
-            throw new TypeError("Source and destination must be ArrayBuffer instances");
-        }
-        if(dest.byteLength >= source.byteLength) {
-            var nextOffset = 0;
-            var leftBytes = source.byteLength;
-            var wordSizes = [8, 4, 2, 1];
-            wordSizes.forEach(function (_wordSize_) {
-                if (leftBytes >= _wordSize_) {
-                    var done = transferWith(_wordSize_, source, dest, nextOffset, leftBytes);
-                    nextOffset = done.nextOffset;
-                    leftBytes = done.leftBytes;
-                }
-            });
-        }
-        return dest;
-        function transferWith(wordSize, source, dest, nextOffset, leftBytes) {
-            var ViewClass = Uint8Array;
-            switch (wordSize)  {
-                case 8:
-                    ViewClass = Float64Array;
-                    break;
-                case 4:
-                    ViewClass = Float32Array;
-                    break;
-                case 2:
-                    ViewClass = Uint16Array;
-                    break;
-                case 1:
-                    ViewClass = Uint8Array;
-                    break;
-                default:
-                    ViewClass = Uint8Array;
-                    break;
-            }
-            var view_source = new ViewClass(source, nextOffset, Math.trunc(leftBytes / wordSize));
-            var view_dest = new ViewClass(dest, nextOffset, Math.trunc(leftBytes / wordSize));
-            for(var i=0; i<view_dest.length; i++) {
-                view_dest[i] = view_source[i];
-            }
-            return {
-                nextOffset : view_source.byteOffset + view_source.byteLength,
-                leftBytes : source.byteLength - (view_source.byteOffset + view_source.byteLength)
-            }
-        }
-    };
-}
- -

规范

- -

Not part of any current specification draft document, but has been proposed for a future ECMA-262 edition.

- -

浏览器兼容性

- - - -

{{Compat("javascript.builtins.ArrayBuffer.transfer")}}

- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaleformat/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/tolocaleformat/index.html deleted file mode 100644 index 40c72fc476..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaleformat/index.html +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: Date.prototype.toLocaleFormat() -slug: Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat -tags: - - Date - - 非标准 -translation_of: Archive/Web/JavaScript/Date.toLocaleFormat ---- -
{{JSRef}} {{non-standard_header}}
- -

非标准方法 toLocaleFormat() 按特定的格式将一个日期转换成一个字符串。 {{jsxref("Global_Objects/DateTimeFormat", "Intl.DateTimeFormat")}} 是符合标准的格式化日期的替代方法。另见更新的(newer)版本的 {{jsxref("Date.prototype.toLocaleDateString()")}}方法.

- -

语法

- -
dateObj.toLocaleFormat(formatString)
- -

参数

- -
-
formatString
-
与C语言中的 strftime() 方法的参数形式要求相同的格式字符串。
-
- -

描述

- -

toLocaleFormat() 方法通过格式化生成的日期或时间提供了更好的软件层面的控制(provides greater software control over the formatting of the generated date and/or time)。用操作系统的地点来月份和星期几的名称本地化。然而,However, ordering of the day and month and other localization tasks are not handled automatically since you have control over the order in which they occur. You should take care that the format string is localized properly according to the user's system settings. Be aware that the locale used is not necessarily the same as the locale of the browser.

- -

Extension and XULRunner developers should know that just loading the format string from a .dtd or .properties file using a chrome://somedomain/locale/somefile.ext URI should be avoided, as the .dtd/.properties file and the toLocaleFormat() method does not not necessarily use the same locale, which could result in odd looking or even ambiguous or unreadable dates.

- -

Also note that the behavior of the used locale depends on the platform, and the user might customize the locale used, so using the system locale the choose the format string might in some cases not even be adequate. You might consider using some of the more general toLocale* methods of the {{jsxref("Global_Objects/Date", "Date")}} object or doing your own custom localization of the date to be displayed using some of the get* methods of the {{jsxref("Global_Objects/Date", "Date")}} object instead of using this method.

- -

示例

- -

Using toLocaleFormat()

- -
var today = new Date();
-var date = today.toLocaleFormat('%A, %B %e, %Y'); // Bad example
-
- -

In this example, toLocaleFormat() returns a string such as "Wednesday, October 3, 2007". Note that the format string in this example is not properly localized, which will result in the problems described above.

- -

腻子(Polyfill)

- -

When using the DateJS library you can polyfill {{jsxref("Date.prototype.toLocaleDateString()")}} like this:

- -
if (!Date.prototype.toLocaleFormat) {
-    (function() {
-        Date.prototype.toLocaleFormat = function(formatString) {
-            return this.format(formatString);
-        };
-    }());
-}
- -

标准

- -

不属于任何标准。在JavaScript 1.6中被实现。

- -

兼容性

- -
- - -

{{Compat("javascript.builtins.Date.toLocaleFormat")}}

-
- -

另见

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/arity/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/arity/index.html deleted file mode 100644 index d8e8668ca2..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/function/arity/index.html +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: Function.arity -slug: Web/JavaScript/Reference/Global_Objects/Function/arity -translation_of: Archive/Web/JavaScript/Function.arity ---- -
-
{{JSRef("Global_Objects", "Function")}} {{obsolete_header}}
-
- -

概述

- -

返回一个函数的形参数量.

- -

描述

- -

arity是一个古老的已经没有浏览器支持的属性,你应该使用Function.prototype.length属性来代替.

diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/isgenerator/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/isgenerator/index.html deleted file mode 100644 index f377f0a210..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/function/isgenerator/index.html +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: Function.prototype.isGenerator() -slug: Web/JavaScript/Reference/Global_Objects/Function/isGenerator -translation_of: Archive/Web/JavaScript/Function.isGenerator ---- -
{{JSRef("Global_Objects", "Function")}} {{non-standard_header}}
- -

概述

- -

判断一个函数是否是一个生成器.

- -

语法

- -
fun.isGenerator()
- -

描述

- -

该方法用来判断一个函数是否是一个生成器.

- -

例子

- -
function f() {}
-function* g() {
-  yield 42;
-}
-console.log("f.isGenerator() = " + f.isGenerator());
-console.log("g.isGenerator() = " + g.isGenerator());
-
- -

上面代码的输出结果为

- -
f.isGenerator() = false
-g.isGenerator() = true
-
- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/iterator/index.html b/files/zh-cn/web/javascript/reference/global_objects/iterator/index.html deleted file mode 100644 index 775c8d60d6..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/iterator/index.html +++ /dev/null @@ -1,188 +0,0 @@ ---- -title: Iterator -slug: Web/JavaScript/Reference/Global_Objects/Iterator -tags: - - Deprecated -translation_of: Archive/Web/Iterator ---- -
{{jsSidebar("Objects")}}
- -
非标准。 Iterator 函数是一个 SpiderMonkey 专有特性,并且会在某一时刻被删除。为将来使用的话,请考虑使用 {{jsxref("Statements/for...of", "for...of")}} 循环和  迭代协议
- -

Iterator 函数返回一个对象,它实现了遗留的迭代协议,并且迭代了一个对象的可枚举属性。

- -

语法

- -
Iterator(object, [keyOnly])
- -

参数

- -
-
object
-
要迭代属性的对象。
-
keyOnly
-
 如果keyOnly是真值,Iterator.prototype.next 只返回property_name
-
- -

描述

- -

返回迭代了object的Iterator 实例。如果keyOnly为假值,则Iterator 实例返回每次迭代而生成的 [property_name, property_value] 数组,否则,如果keyOnly是真值,则它返回每次迭代的 property_name。如果objectIterator 实例或 {{jsxref("Generator")}} 实例 ,则它返回 object 自身。

- -

属性

- -
-
Iterator.prototype[@@iterator]
-
返回一个函数,它返回符合{{jsxref("Iteration_protocols", "迭代协议", "", 1)}}的迭代对象。
-
- -

方法

- -
-
Iterator.prototype.next
-
返回[property_name, property_value] 格式或property_name 的下一项。 如果没有更多项,抛出 StopIteration
-
- -

示例

- -

迭代一个对象的属性

- -
var a = {
-  x: 10,
-  y: 20,
-};
-var iter = Iterator(a);
-console.log(iter.next()); // ["x", 10]
-console.log(iter.next()); // ["y", 20]
-console.log(iter.next()); // throws StopIteration
-
- -

使用遗留的解构for-in迭代对象的属性

- -
var a = {
-  x: 10,
-  y: 20,
-};
-
-for (var [name, value] in Iterator(a)) {
-  console.log(name, value);   // x 10
-                              // y 20
-}
-
- -

使用for-of迭代

- -
var a = {
-  x: 10,
-  y: 20,
-};
-
-for (var [name, value] of Iterator(a)) {  // @@iterator is used
-  console.log(name, value);   // x 10
-                              // y 20
-}
-
- -

迭代属性名

- -
var a = {
-  x: 10,
-  y: 20,
-};
-
-for (var name in Iterator(a, true)) {
-  console.log(name);   // x
-                       // y
-}
-
- -

传入 Generator 实例

- -
function* f() {
-  yield 'a';
-  yield 'b';
-}
-var g = f();
-
-console.log(g == Iterator(g)); // true
-
-for (var v in Iterator(g)) {
-  console.log(v);   // a
-                    // b
-}
-
- -

传入 Iterator 实例

- -
var a = {
-  x: 10,
-  y: 20,
-};
-
-var i = Iterator(a);
-
-console.log(i == Iterator(i)); // true
-
- -

规范

- -

非标准。不是目前任何标准文档的一部分。

- -

浏览器兼容性

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/tointeger/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/tointeger/index.html deleted file mode 100644 index 24abe2125e..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/number/tointeger/index.html +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: Number.toInteger() -slug: Web/JavaScript/Reference/Global_Objects/Number/toInteger -translation_of: Archive/Web/JavaScript/Number.toInteger ---- -
{{JSRef("Global_Objects", "Number")}} {{obsolete_header("33")}} {{non-standard_header}}
- -

概览

- -

Number.toInteger() 用来将参数转换成整数,但该方法的实现已被移除.

- -

如果参数是 {{jsxref("Global_Objects/NaN", "NaN")}}, {{jsxref("Global_Objects/null", "null")}} 或 {{jsxref("Global_Objects/undefined", "undefined")}}, 会返回0 . 如果参数值是true返回1,false的话返回0.

- -

语法

- -
Number.toInteger(number)
- -

参数

- -
-
number
-
将被转换成整数的参数.
-
- -

示例

- -

例子: 使用 toInteger()方法

- -
Number.toInteger(0.1);     // 0
-Number.toInteger(1);       // 1
-Number.toInteger(Math.PI); // 3
-Number.toInteger(null);    // 0
-
- -

Specifications

- - - -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}Firefox 16 to 32{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}Firefox 16 to 32{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

See also

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/count/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/count/index.html deleted file mode 100644 index c7dfb12f2b..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/count/index.html +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: Object.prototype.__count__ -slug: Web/JavaScript/Reference/Global_Objects/Object/count -tags: - - JavaScript - - Object - - Obsolete - - Property - - Prototype -translation_of: Archive/Web/JavaScript/Object.count ---- -
{{JSRef}} {{obsolete_header("2")}}
- -

 __count__ 属性曾经用来存放对象的可枚举的属性的个数,但是已经被废除。

- -

语法

- -
obj.__count__
- -

示例

- -
{ 1: 1 }.__count__              // 1
-[].__count__                    // 0
-[1].__count__                   // 1
-[1, /* hole */, 2, 3].__count__ // 3
-
- -

详细说明

- -

无需详细说明

- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

更多请参看

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/eval/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/eval/index.html deleted file mode 100644 index e823c314a8..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/eval/index.html +++ /dev/null @@ -1,85 +0,0 @@ ---- -title: Object.prototype.eval() -slug: Web/JavaScript/Reference/Global_Objects/Object/eval -translation_of: Archive/Web/JavaScript/Object.eval ---- -
{{JSRef}} {{obsolete_header}}
- -

Object.eval() 方法用于在对象的上下文中对 JavaScript 代码字符串求值,但该方法已被移除。

- -

语法

- -
obj.eval(string)
- -

参数

- -
-
string
-
包含任意 JavaScript 表达式、语句或一组语句的字符串。表达式中可包含已有对象的变量与属性。
-
- -

描述

- -

eval 方法已从对象方法中移除。可使用全局 {{jsxref("Global_Objects/eval", "eval()")}} 函数替代该方法。

- -

规范

- -

暂无规范

- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getnotifier/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getnotifier/index.html deleted file mode 100644 index fac0573de3..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getnotifier/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Object.getNotifier() -slug: Web/JavaScript/Reference/Global_Objects/Object/getNotifier -translation_of: Archive/Web/JavaScript/Object.getNotifier ---- -
{{JSRef}} {{obsolete_header}}
- -

Object.getNotifer() 方法用于创建可人工触发 change 事件的对象,但该方法在浏览器中已被废弃。

- -

语法

- -
Object.getNotifier(obj)
- -

参数

- -
-
obj
-
获取通知的对象。
-
- -

返回值

- -

与传入对象相关联的通知对象。

- -

描述

- -

通知对象可触发 Object.observe() 所观察到的人工变动。

- -

规范

- -

Strawman proposal specification.

- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("36")}} [1]{{CompatNo}}{{CompatNo}}{{CompatOpera("23")}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatChrome("36")}} [1]{{CompatNo}}{{CompatNo}}{{CompatOpera("23")}}{{CompatNo}}
-
- -

[1] Deprecated in Chrome 49.

- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/nosuchmethod/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/nosuchmethod/index.html deleted file mode 100644 index 7b54198c19..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/nosuchmethod/index.html +++ /dev/null @@ -1,208 +0,0 @@ ---- -title: Object.prototype.__noSuchMethod__ -slug: Web/JavaScript/Reference/Global_Objects/Object/noSuchMethod -translation_of: Archive/Web/JavaScript/Object.noSuchMethod ---- -
{{JSRef}} {{obsolete_header}}
- -

__noSuchMethod__ 属性曾经是指当调用某个对象里不存在的方法时即将被执行的函数,但是现在这个函数已经不可用。

- -

__noSuchMethod__ 属性被移除之后,ECMAScript 2015 (ES6) 规范转而采用 {{jsxref("Proxy")}} 对象, 可以实现下面的效果(以及更多)。

- -

语法

- -
obj.__noSuchMethod__ = fun
- -

参数

- -
-
fun
-
函数形式如下:
-
-
function (id, args) { . . . }
- -
-
id
-
调用的不存在的方法名
-
args
-
传递给该方法的参数数组
-
-
-
- -

描述

- -

默认情况喜爱,试图调用对象上不存在的方法其结果是在{{jsxref("TypeError")}}上抛出异常,这种行为可以在

- -

By default, an attempt to call a method that doesn't exist on an object results in a {{jsxref("TypeError")}} being thrown. This behavior can be circumvented by defining a function at that object's __noSuchMethod__ member. The function takes two arguments, the first is the name of the method attempted and the second is an array of the arguments that were passed in the method call. The second argument is an actual array (that is, it inherits through the {{jsxref("Array.prototype")}} chain) and not the array-like arguments object.

- -

If this method cannot be called, either as if undefined by default, if deleted, or if manually set to a non-function, the JavaScript engine will revert to throwing TypeErrors.

- -

Examples

- -

Simple test of __noSuchMethod__

- -
var o = {
-  __noSuchMethod__: function(id, args) {
-                      console.log(id, '(' + args.join(', ') + ')');
-                    }
-};
-
-o.foo(1, 2, 3);
-o.bar(4, 5);
-o.baz();
-
-// Output
-// foo (1, 2, 3)
-// bar (4, 5)
-// baz ()
-
- -

Using __noSuchMethod__ to simulate multiple inheritance

- -

An example of code that implements a primitive form of multiple inheritance is shown below.

- -
// Doesn't work with multiple inheritance objects as parents
-function noMethod(name, args) {
-  var parents = this.__parents_;
-
-  // Go through all parents
-  for (var i = 0; i < parents.length; i++) {
-    // If we find a function on the parent, we call it
-    if (typeof parents[i][name] == "function") {
-      return parents[i][name].apply(this, args);
-    }
-  }
-
-  // If we get here, the method hasn't been found
-  throw new TypeError;
-}
-
-// Used to add a parent for multiple inheritance
-function addParent(obj, parent) {
-  // If the object isn't initialized, initialize it
-  if (!obj.__parents_) {
-    obj.__parents_ = [];
-    obj.__noSuchMethod__ = noMethod;
-  }
-
-  // Add the parent
-  obj.__parents_.push(parent);
-}
-
- -

An example of using this idea is shown below.

- -
// Example base class 1
-function NamedThing(name){
-  this.name=name;
-}
-
-NamedThing.prototype = {
-  getName: function() { return this.name; },
-  setName: function(newName) { this.name = newName; }
-}
-
-// Example base class 2
-function AgedThing(age) {
-  this.age = age;
-}
-
-AgedThing.prototype = {
-  getAge: function() { return this.age; },
-  setAge: function(age) { this.age = age; }
-}
-
-// Child class. inherits from NamedThing and AgedThing
-// as well as defining address
-function Person(name, age, address){
-  addParent(this, NamedThing.prototype);
-  NamedThing.call(this, name);
-  addParent(this, AgedThing.prototype);
-  AgedThing.call(this, age);
-  this.address = address;
-}
-
-Person.prototype = {
-  getAddr: function() { return this.address; },
-  setAddr: function(addr) { this.address = addr; }
-}
-
-var bob = new Person("bob", 25, "New York");
-
-console.log("getAge is " + (("getAge" in bob) ? "in" : "not in") + " bob");
-// getAge is not in bob
-
-console.log("bob's age is: " + bob.getAge());
-// bob's age is: 25
-
-console.log("getName is " + (("getName" in bob) ? "in" : "not in") + " bob");
-// getName is not in bob
-
-console.log("bob's name is: " + bob.getName());
-// bob's name is: bob
-
-console.log("getAddr is " + (("getAddr" in bob) ? "in" : "not in") + " bob");
-// getAddr is in bob
-
-console.log("bob's address is: " + bob.getAddr());
-// bob's address is: New York
-
- -

Specifications

- -

Not part of any specifications. This feature has been removed, see {{bug(683218)}}.

- -

Browser compatibility

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatNo}} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

[1] This feature was implemented until version 43.

diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/observe/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/observe/index.html deleted file mode 100644 index e37cc6ab6f..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/observe/index.html +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: Object.observe() -slug: Web/JavaScript/Reference/Global_Objects/Object/observe -tags: - - ECMAScript7 - - Experimental - - JavaScript - - Method - - Object - - observe -translation_of: Archive/Web/JavaScript/Object.observe ---- -
{{JSRef}} {{obsolete_header}}
- -

概述

- -

Object.observe() 方法用于异步地监视一个对象的修改。当对象属性被修改时,方法的回调函数会提供一个有序的修改流。然而,这个接口已经被废弃并从各浏览器中移除。你可以使用更通用的 {{jsxref("Proxy")}} 对象替代。

- -

语法

- -
Object.observe(obj, callback[, acceptList])
- -

参数

- -
-
obj
-
被监控的对象.
-
callback
-
当对象被修改时触发的回调函数,其参数为: -
-
changes
-
一个数组,其中包含的每一个对象代表一个修改行为。每个修改行为的对象包含: -
    -
  • name: 被修改的属性名称
  • -
  • object: 修改后该对象的值
  • -
  • type: 表示对该对象做了何种类型的修改,可能的值为"add", "update", or "delete"
  • -
  • oldValue: 对象修改前的值。该值只在"update""delete"有效。
  • -
  •  
  • -
-
-
acceptList
-
在给定对象上给定回调中要监视的变化类型列表。如果省略, ["add", "update", "delete", "reconfigure", "setPrototype", "preventExtensions"] 将会被使用。
-
-
-
- -

描述

- -

callback 函数会在对象被改变时被调用,其参数为一个包含所有修改信息的有序的数组对象。

- -

例子

- -

例子: 打印出三种不同操作类型的日志

- -
var obj = {
-  foo: 0,
-  bar: 1
-};
-
-Object.observe(obj, function(changes) {
-  console.log(changes);
-});
-
-obj.baz = 2;
-// [{name: 'baz', object: <obj>, type: 'add'}]
-
-obj.foo = 'hello';
-// [{name: 'foo', object: <obj>, type: 'update', oldValue: 0}]
-
-delete obj.baz;
-// [{name: 'baz', object: <obj>, type: 'delete', oldValue: 2}]
-
- -

例子: 数据绑定

- -
// 一个数据模型
-var user = {
-  id: 0,
-  name: 'Brendan Eich',
-  title: 'Mr.'
-};
-
-// 创建用户的greeting
-function updateGreeting() {
-  user.greeting = 'Hello, ' + user.title + ' ' + user.name + '!';
-}
-updateGreeting();
-
-Object.observe(user, function(changes) {
-  changes.forEach(function(change) {
-    // 当name或title属性改变时, 更新greeting
-    if (change.name === 'name' || change.name === 'title') {
-      updateGreeting();
-    }
-  });
-});
-
- -

规范

- -

Strawman proposal for ECMAScript 7.

- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("36")}}{{CompatNo}}{{CompatNo}}{{CompatOpera("23")}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatChrome("36")}}{{CompatNo}}{{CompatNo}}{{CompatOpera("23")}}{{CompatNo}}
-
- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/parent/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/parent/index.html deleted file mode 100644 index 8597b6c4a3..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/parent/index.html +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: Object.prototype.__parent__ -slug: Web/JavaScript/Reference/Global_Objects/Object/Parent -tags: - - JavaScript - - 原型 - - 对象 - - 属性 - - 已废弃 - - 非标准 -translation_of: Archive/Web/JavaScript/Object.parent ---- -
{{JSRef}}{{Non-standard_Header}}{{Obsolete_Header("gecko2")}}
- -

The __parent__ property used to point to an object's context, but it has been removed.

- -

指向一个对象的上下文.

- -

语法

- -
obj.__parent__
- -

描述

- -

对于最顶层对象来说,这个属性的值就是全局对象 window。

- -

规范

- -

不属于任何规范。

- -

浏览器兼容性

- - - -

{{Compat("javascript.builtins.Object.parent")}}

- -

参见

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/unobserve/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/unobserve/index.html deleted file mode 100644 index bcae6ae8e7..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/unobserve/index.html +++ /dev/null @@ -1,133 +0,0 @@ ---- -title: Object.unobserve() -slug: Web/JavaScript/Reference/Global_Objects/Object/unobserve -translation_of: Archive/Web/JavaScript/Object.unobserve ---- -
{{JSRef}} {{non-standard_header}}
- -

Object.unobserve() 是用来移除通过 {{jsxref("Object.observe()")}}设置的观察者的方法。

- -

语法

- -
Object.unobserve(obj, callback)
- -

参数

- -
-
obj
-
需要停止观察的对象。
-
callback
-
通过 observer 给 obj 对象设置的回调函数.
-
- -

描述

- -

Object.unobserve() 用来在 {{jsxref("Object.observe()")}} 被调用以后,从对象上移除一个观察者。

- -

这个回调函数必须是一个函数的引用,而不能是一个匿名函数。因为这个引用将被用来移除之前设置的观察者方法。 给 Object.unobserve() 传入匿名函数作为回调是不起作用的, 它不能移除任何观察者方法。

- -

例子

- -

观察一个对象

- -
var obj = {
-  foo: 0,
-  bar: 1
-};
-
-var observer = function(changes) {
-  console.log(changes);
-}
-
-Object.observe(obj, observer);
-​
-obj.newProperty = 2;
-// [{name: 'newProperty', object: <obj>, type: 'add'}]
-
-Object.unobserve(obj, observer);
-
-obj.foo = 1;
-// 回调函数不会被调用
- -

使用匿名函数

- -
var person = {
-  name : 'Ahmed',
-  age : 25
-};
-
-Object.observe(person, function (changes) {
-  console.log(changes);
-});
-
-person.age = 40;
-// [{name: 'age', object: <obj>, oldValue: 25, type: 'update'}]
-
-Object.unobserve(person, function (changes) {
-  console.log(changes);
-});
-
-person.age = 63;
-// [{name: 'age', object: <obj>, oldValue: 40, type: 'update'}]
-// 回调函数将会被调用
-
- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("36")}}{{CompatNo}}{{CompatNo}}{{CompatOpera("23")}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatChrome("36")}}{{CompatNo}}{{CompatNo}}{{CompatOpera("23")}}{{CompatNo}}
-
- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/unwatch/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/unwatch/index.html deleted file mode 100644 index 986154992d..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/unwatch/index.html +++ /dev/null @@ -1,105 +0,0 @@ ---- -title: Object.prototype.unwatch() -slug: Web/JavaScript/Reference/Global_Objects/Object/unwatch -translation_of: Archive/Web/JavaScript/Object.unwatch ---- -
{{JSRef}}
- -
-

警告 : 请尽量避免使用 unwatch() 和  {{jsxref("Object.prototype.watch", "watch()")}} . 这两个方法仅在 Gecko 中实现 , 并且他们过去主要作调试用. 另外, 使用 watchpoints 对性能有一系列的副面影响 ,特别是当使用全局对象,如 window. 你应该使用  setters and getters 或 proxies 来替代. 查阅 {{anch("Browser compatibility")}} 以获取更多信息.

-
- -

unwatch() 删除一个 {{jsxref("Object.prototype.watch", "watch()")}} 设置的 watchpoint.

- -

语法

- -
obj.unwatch(prop)
- -

参数

- -
-
prop
-
想要停止监视的对象的属性名
-
- -

描述

- -

JavaScript调试器具有类似的功能,以及其他调试选项。有关调试器的信息  Venkman.

- -

默认地, 这个方法 被每一个 {{jsxref("Object")}} 的子类继承 

- -
-

Note: The reason for unwatch() to take the property name prop as its only parameter is due to the "single handler allowing" behavior of the {{jsxref("Object.watch", "watch()")}} method.

-
- -

例子

- -

See {{jsxref("Object.watch", "watch()")}}.

- -

说明

- -

Not part of any specifications. Implemented in JavaScript 1.2.

- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

Compatibility notes

- - - -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/watch/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/watch/index.html deleted file mode 100644 index 540967eee3..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/object/watch/index.html +++ /dev/null @@ -1,201 +0,0 @@ ---- -title: Object.prototype.watch() -slug: Web/JavaScript/Reference/Global_Objects/Object/watch -tags: - - Debugging - - Deprecated - - JavaScript - - Method - - Object - - Obsolete - - Prototype -translation_of: Archive/Web/JavaScript/Object.watch ---- -

{{JSRef}}

- -
-

警告: 通常来讲,你应该尽量避免使用 watch()和  {{jsxref("Object.prototype.unwatch", "unwatch()")}} 这两个方法。因为只有 Gecko 实现了这两个方法,并且它们主要是为了在调试方便。另外,使用 watchpoint 对性能有严重的负面影响,在全局对象(如 window)上使用时尤其如此。你可以使用 setters and getters 或者 proxy 代替。参见 {{ anch("Compatibility") }} 了解详情。

-
- -

watch() 方法会监视属性是否被赋值并在赋值时运行相关函数。

- -

语法

- -
obj.watch(prop, handler)
- -

参数

- -
-
prop
-
想要监视值是否发生变化的指定对象的某个属性的属性名称
-
- -
-
handler
-
当指定的属性发生变化时执行的回调函数
-
- -

返回值

- -

{{jsxref("undefined")}}.

- -

描述

- -

监视对指定对象的名为 prop 属性的赋值操作,只要 prop 属性被赋值,便调用 handler(prop, oldval, newval) 回调函数,并将函数返回值保存到该属性。 通过返回修改的新值(或者返回旧值),一个监视点可以过滤(或使之为 null )赋值。

- -

如果你删除某个设置监视点的属性,该监视点并不会消失。如果你之后重新创建这个属性,监视点仍然有效。

- -

要移除某个监视点,使用 unwatch() 方法。默认所有 Object 的后代都将继承 watch 方法。

- -

JavaScript 调试器有与之相似的机制以及其它调试选项。需要更多有关调试器的信息,请查阅 Venkman

- -

对于 Firefox,handler 只会被脚本内的赋值操作激活,并不包括本地代码。举个例子,如果用户点击一个指向当前文档内的某个锚点, window.watch('location', myHandler) 不会回调 myHandler ,但 window.location += '#myAnchor' 将触发回调  myHandler

- -
注意: 对一个对象的指定属性调用 watch()  将覆盖先前关联的 handler。
- -

例子

- -

使用 watchunwatch

- -
var o = {p:1};
-o.watch("p",
-  function (id, oldval, newval) {
-    console.log("o." + id + "由" + oldval + " 变为 " + newval);
-    return newval;
-  });
-
-o.p = 2;
-o.p = 3;
-delete o.p;
-o.p = 4;
-
-o.unwatch('p');
-o.p = 5;
-
- -

上面的代码显示结果如下:

- -
o.p 由 1 变为 2
-o.p 由 2 变为 3
-o.p 由 undefined 变为 4
-
- -

使用 watch 来验证一个对象的属性

- -

你可以使用 watch 来检测一个对象的属性赋值是否是合法的.下例演示了如何确保每个人始终具有一个合法的名字和0 到 200之间的年龄.

- -
Person = function(name,age) {
-  this.watch("age", Person.prototype._isValidAssignment);
-  this.watch("name", Person.prototype._isValidAssignment);
-  this.name = name;
-  this.age = age;
-}
-
-Person.prototype.toString = function() {
-  return this.name + ", " + this.age;
-};
-
-Person.prototype._isValidAssignment = function(id, oldval, newval) {
-  if (id === "name" && (!newval || newval.length > 30)) {
-    throw new RangeError("不合法的名字 " + this);
-  }
-  if (id === "age"  && (newval < 0 || newval > 200)) {
-    throw new RangeError("不合法的年龄 " + this);
-  }
-  return newval;
-}
-
-will = new Person("Will", 29);
-print(will);   // Will, 29
-
-try {
-  will.name = "";
-} catch (e) {
-  //print(e);
-  console.log(e);
-}
-
-try {
-  will.age = -4;
-} catch (e) {
-  console.log(e);
-}
-
- -

上面的代码显示结果如下:

- -
Will, 29
-RangeError: 不合法的名字 Will, 29
-RangeError: 不合法的年龄 Will, 29
-
- -

Specifications

- -

不是任何规范的一部分。从 JavaScript 1.2 开始实现。

- -

Browser compatibility

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

兼容性提示

- - - -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/parallelarray/index.html b/files/zh-cn/web/javascript/reference/global_objects/parallelarray/index.html deleted file mode 100644 index 739d25c173..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/parallelarray/index.html +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: ParallelArray -slug: Web/JavaScript/Reference/Global_Objects/ParallelArray -tags: - - JavaScript - - ParallelArray - - 过时 -translation_of: Archive/Web/ParallelArray ---- -

The goal of ParallelArray was to enable data-parallelism in web applications. The higher-order functions available on ParallelArray attempted to execute in parallel, though they may fall back to sequential execution if necessary. To ensure that your code executes in parallel, it is suggested that the functions should be limited to the parallelizable subset of JS that Firefox supports.

- -

语法

- -
new ParallelArray()
-new ParallelArray([element0, element1, ...])
-new ParallelArray(arrayLength, elementalFunction)
- -

ParallelArray instances

- -

属性

- -
-
length
-
Reflects the number of elements in the ParallelArray.
-
- -

方法

- -
-
map
-
reduce
-
scan
-
scatter
-
filter
-
flatten
-
partition
-
get
-
- -

示例

- -

Using map in parallel

- -
var p = new ParallelArray([0, 1, 2, 3, 4]);
-var m = p.map(function (v) {
-  return v + 1;
-});
- -

参见

- - diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/quote/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/quote/index.html deleted file mode 100644 index 3d8d197f46..0000000000 --- a/files/zh-cn/web/javascript/reference/global_objects/string/quote/index.html +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: String.prototype.quote() -slug: Web/JavaScript/Reference/Global_Objects/String/quote -tags: - - JavaScript - - Method - - Non-standard - - Obsolete - - Prototype - - String -translation_of: Archive/Web/JavaScript/String.quote ---- -
{{obsolete_header("37")}}
- -
{{JSRef("Global_Objects", "String")}}{{Non-standard_header}}
- -

概述

- -

将字符串中包含的特殊字符进行转义(反斜杠),然后在字符串两边各加上一个双引号(")并返回,并不修改原字符串.

- -

语法

- -
str.quote()
- -

示例

- - - - - - - - - - - - - - - - - - - - - - - - - - -
strstr.quote()eval(str.quote())
Hello world!"Hello world!"Hello world!
Hello
-         world!
"Hello\n\tworld!"Hello
-         world!
" \ — '"\" \\ \u2014 '"" \ — '
- -

规范

- -

不在任何规范中。实现于 JavaScript 1.3.

- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/operators/array_comprehensions/index.html b/files/zh-cn/web/javascript/reference/operators/array_comprehensions/index.html deleted file mode 100644 index 8bdfa28db2..0000000000 --- a/files/zh-cn/web/javascript/reference/operators/array_comprehensions/index.html +++ /dev/null @@ -1,157 +0,0 @@ ---- -title: 数组推导式 -slug: Web/JavaScript/Reference/Operators/Array_comprehensions -tags: - - JavaScript - - Non-standard - - 参考 - - 运算符 -translation_of: Archive/Web/JavaScript/Array_comprehensions ---- -
-

非标准。不要使用!
- 数组推导是非标准的。以后应该用 {{jsxref("Array.prototype.map")}},{{jsxref("Array.prototype.filter")}},{{jsxref("Functions/Arrow_functions", "箭头函数", "", 1)}}和{{jsxref("Operators/Spread_operator", "展开语法", "", 1)}}.。

-
- -

{{jsSidebar("Operators")}} 

- -

数组推导式是一种 JavaScript 表达式语法,使用它,你可以在一个原有数组的基础上快速的构造出一个新的数组。但是它已经从标准和火狐中移除。不要用它!

- -

语法

- -
[for (x of iterable) x]
-[for (x of iterable) if (condition) x]
-[for (x of iterable) for (y of iterable) x + y]
-
- -

描述

- -

在数组推导式内部,可以使用下面两种子语句:

- - - -

每个 for-of 语句都放在与其配对的 if 语句(可以有多个,也可以完全省略)的左边,每个数组推导式中可以包含多组这样的配对,但最终选取的表达式值只能有一个,且这个值(也可以是个数组推导式,也就是说可以嵌套)只能放在推导式的最右边,紧靠着右中括号。

- -

示例

- -

基本的数组推导式写法

- -
[for (i of [ 1, 2, 3 ]) i*i ];
-// [ 1, 4, 9 ]
-
-var abc = [ "A", "B", "C" ];
-[for (letters of abc) letters.toLowerCase()];
-// [ "a", "b", "c" ]
- -

带有 if 语句的数组推导式

- -
var years = [ 1954, 1974, 1990, 2006, 2010, 2014 ];
-
-[for (year of years) if (year > 2000) year];
-// [ 2006, 2010, 2014 ]
-
-[for (year of years) if (year > 2000) if(year < 2010) year];
-// [ 2006], 和下面的写法等效:
-
-[for (year of years) if (year > 2000 && year < 2010) year];
-// [ 2006]
-
- -

用数组推导式比用数组的 mapfilter 方法更简洁

- -

对比数组的 {{jsxref("Array.map", "map")}} 和 {{jsxref("Array.filter", "filter")}} 方法:

- -
var numbers = [ 1, 2, 3 ];
-
-numbers.map(function (i) { return i * i });
-[for (i of numbers) i*i ];
-// 返回值都是 [ 1, 4, 9 ]
-
-numbers.filter(function (i) { return i < 3 });
-[for (i of numbers) if (i < 3) i];
-// 返回值都是 [ 1, 2 ]
-
- -

带有两个数组的数组推导式

- -

用两个 for-of 语句迭代两个不同的数组:

- -
var numbers = [ 1, 2, 3 ];
-var letters = [ "a", "b", "c" ];
-
-var cross = [for (i of numbers) for (j of letters) i+j];
-// [ "1a", "1b", "1c", "2a", "2b", "2c", "3a", "3b", "3c" ]
-
-var grid = [for (i of numbers) [for (j of letters) i+j]];
-// [
-//  ["1a", "1b", "1c"],
-//  ["2a", "2b", "2c"],
-//  ["3a", "3b", "3c"]
-// ]
-
-[for (i of numbers) if (i > 1) for (j of letters) if(j > "a") i+j]
-// ["2b", "2c", "3b", "3c"],和下面的写法等效:
-
-[for (i of numbers) for (j of letters) if (i > 1) if(j > "a") i+j]
-// ["2b", "2c", "3b", "3c"]
-
-[for (i of numbers) if (i > 1) [for (j of letters) if(j > "a") i+j]]
-// [["2b", "2c"], ["3b", "3c"]],和下面的写法不等效:
-
-[for (i of numbers) [for (j of letters) if (i > 1) if(j > "a") i+j]]
-// [[], ["2b", "2c"], ["3b", "3c"]]
-
- -

规范

- -

最初起草在ECMAScript 6草案中,但在第27版(2014年8月)中被移除。 请参阅ES 6的旧修订版的规范语义。

- -

浏览器兼容性

- - - -

{{Compat("javascript.operators.array_comprehensions")}}

- -

同旧版的JS1.7/JS1.8数组推导的不同之处

- -

 

- -
JS1.7/JS1.8数组推导 在Gecko的46版本中已经被移除了 ({{bug(1220564)}}).
- -

旧版数组推导语法 (请不要再使用了!):

- -
[X for (Y in Z)]
-[X for each (Y in Z)]
-[X for (Y of Z)]
-
- -

不同点:

- - - -

点击查看 Bug 1220564, comment 42 并提出建设性建议.

- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/operators/expression_closures/index.html b/files/zh-cn/web/javascript/reference/operators/expression_closures/index.html deleted file mode 100644 index e5dee577bc..0000000000 --- a/files/zh-cn/web/javascript/reference/operators/expression_closures/index.html +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: Expression closures -slug: Web/JavaScript/Reference/Operators/Expression_closures -tags: - - Functions - - JavaScript - - Reference -translation_of: Archive/Web/JavaScript/Expression_closures ---- -
非标准,不要使用!
-闭包表达式语法是废弃的 SpiderMonkey 的特性,并且将被移除。为了长远使用,考虑使用箭头函数
- -
{{jsSidebar("Operators")}}
- -

表达式闭包是定义简单函数的一种便捷方式。

- -

语法

- -
function [name]([param1[, param2[, ..., paramN]]])
-   expression
-
- -

参数

- -
-
name
-
函数名。函数名可以省略不写,称为匿名函数。函数名仅在函数体有效。
-
paramN
-
形参名。一个函数最多可以有255个参数。
-
expression
-
构成函数体的表达式。
-
- -

描述

- -

这一附加特性只是编写简单函数的快捷方式,让语言更类似通常的 Lambda 标记

- -

JavaScript 1.7 及之前版本:

- -
function(x) { return x * x; }
- -

JavaScript 1.8:

- -
function(x) x * x
- -

该语法支持省略花括号和'return'语句。使用这种编码的目的只是为了在句法上使得代码更加简化,但除此之外没有其他好处。

- -

示例

- -

一种绑定事件监听器的便捷方式:

- -
 document.addEventListener("click", function() false, true);
-
- -

在 JavaScript 1.6 中的一些数组函数中使用该标记:

- -
elems.some(function(elem) elem.type == "text");
-
- -

浏览器兼容

- - - -

{{Compat("javascript.operators.expression_closures")}}

- -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/operators/generator_comprehensions/index.html b/files/zh-cn/web/javascript/reference/operators/generator_comprehensions/index.html deleted file mode 100644 index 1442d50019..0000000000 --- a/files/zh-cn/web/javascript/reference/operators/generator_comprehensions/index.html +++ /dev/null @@ -1,193 +0,0 @@ ---- -title: Generator推导式 -slug: Web/JavaScript/Reference/Operators/Generator_comprehensions -translation_of: Archive/Web/JavaScript/Generator_comprehensions ---- -
非标准的。不要使用!
-generator推导式是非标准的,而且它不太可能会被添加到ECMAScript。考虑到将来,请使用 {{jsxref("Statements/function*", "generator", "", 1)}}。 -

 

-
- -

{{jsSidebar("Operators")}}

- -

生成器推导语法是一种JavaScript表达式,它允许您基于现有的可迭代对象快速组合新的生成器函数。

- -

许多编程语言中都存在推导。

- -

看下面,原来Generator推导式语法在SpiderMonkey的不同之处,它是基于对ECMAScript4的提议。

- -

语法

- -
(for (x of iterable) x)
-(for (x of iterable) if (condition) x)
-(for (x of iterable) for (y of iterable) x + y)
-
- -

描述

- -

在Generator推导式中,这两种构成方式都是允许的:

- - - -

for-of迭代器是构成的第一个部分。当由多重部分构成时,后面for-of和if构成方式都是被允许的。

- -

示例

- -

单个构成部分的 generator推导式:

- -
(for (i of [ 1, 2, 3 ]) i*i );
-// generator function which yields 1, 4, and 9
-
-[...(for (i of [ 1, 2, 3 ]) i*i )];
-// [1, 4, 9]
-
-var abc = [ "A", "B", "C" ];
-(for (letters of abc) letters.toLowerCase());
-// generator function which yields "a", "b", and "c"
-
-
- -

有if伴随的多重构成的gennerator推导式:

- -
var years = [ 1954, 1974, 1990, 2006, 2010, 2014 ];
-
-(for (year of years) if (year > 2000) year);
-// generator function which yields 2006, 2010, and 2014
-
-(for (year of years) if (year > 2000) if(year < 2010) year);
-// generator function which yields 2006, the same as below:
-
-(for (year of years) if (year > 2000 && year < 2010) year);
-// generator function which yields 2006
-
- -

Generator推导式与Generator函数对比

- -

用一种简单的方式来理解generator推导式的语法并与generator函数来做个比较。

- -

Example 1: 仅是 generator.

- -
var numbers = [ 1, 2, 3 ];
-
-// Generator 函数
-(function*() {
-  for (let i of numbers) {
-    yield i * i;
-  }
-})()
-
-// Generator 推导式
-(for (i of numbers) i*i );
-
-// 结果: 两者都得到 yields [ 1, 4, 9 ]
-
- -

Example 2: 在 generator 中用if.

- -
var numbers = [ 1, 2, 3 ];
-
-// Generator 函数
-(function*() {
-  for (let i of numbers) {
-    if (i < 3) {
-      yield i * 1;
-    }
-  }
-})()
-
-// Generator 推导式
-(for (i of numbers) if (i < 3) i);
-
-// 结果: 两者都得到 yields [ 1, 2 ]
- -

规范

- -

Generator推导式是最初在ECMAScript 2015中进行拟稿,但是在14年8月27号修订中被移除了。 请参阅较旧版本的ES2015规范语义.

- -

浏览器兼容性

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatNo}}{{ CompatGeckoDesktop("30") }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatNo}}{{ CompatGeckoMobile("30") }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

SpiderMonkey的具体实现笔记

- - - -

与旧的JS1.7 / JS1.8理解的区别

- - - -

相关链接

- - diff --git a/files/zh-cn/web/javascript/reference/statements/for_each...in/index.html b/files/zh-cn/web/javascript/reference/statements/for_each...in/index.html deleted file mode 100644 index 05c1043588..0000000000 --- a/files/zh-cn/web/javascript/reference/statements/for_each...in/index.html +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: for each...in -slug: Web/JavaScript/Reference/Statements/for_each...in -translation_of: Archive/Web/JavaScript/for_each...in ---- -
{{jsSidebar("Statements")}}
- -

使用一个变量迭代一个对象的所有属性值,对于每一个属性值,有一个指定的语句块被执行。

- -
-
-

作为ECMA-357(E4X)标准的一部分,for each...in语句已被废弃,E4X中的大部分特性已被删除,但考虑到向后兼容,for each...in只会被禁用而不会被删除,可以使用ES6中新的for...of语句来代替。({{ bug("791343")}}.)

-
- -
for each...inECMA-357 (E4X) 标准的一部分,大部分非Mozilla浏览器都没有实现该标准,E4X并不是 ECMAScript 标准的一部分。
-
- -

语法

- -
for each (variable in object) {
-  statement
-}
- -

参数

- -
-
variable
-
用来遍历属性值的变量,前面的var关键字是可选的。该变量是函数的局部变量而不是语句块的局部变量。
-
- -
-
object
-
属性值会被遍历的对象。
-
- -
-
statement
-
遍历属性时执行的语句。如果想要执行多条语句,请用块语句({ ... }) 将多条语句括住。
-
- -

描述

- -

一些对象的内置属性是无法被遍历到的,包括所有的内置方法,例如String对象的indexOf方法。不过,大部分的用户自定义属性都是可遍历的.

- -

示例

- -

例子: 使用for each...in

- -

警告:永远不要使用for each...in语句遍历数组,仅用来遍历常规对象。这里讲解了为什么这么说

- -

下面的代码片段演示如何遍历一个对象的属性值,并计算它们的和:

- -
var sum = 0;
-var obj = {prop1: 5, prop2: 13, prop3: 8};
-
-for each (var item in obj) {
-  sum += item;
-}
-
-print(sum); // 输出"26",也就是5+13+8的值
- -

参见

- - -- cgit v1.2.3-54-g00ecf