aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/new_in_javascript/1.8.5/index.html
blob: a61a892e705220dd113ecf024c8d22a024b712ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
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
---
<div>{{jsSidebar("New_in_JS")}}</div>

<p>下面的内容是JavaScript 1.8.5的更新记录. 该版本已包含在<a href="/en-US/Firefox/Releases/4">Firefox 4</a>中.</p>

<h2 id="JavaScript_1.8.5的新特性">JavaScript 1.8.5的新特性</h2>

<h3 id="新函数">新函数</h3>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Function</th>
   <th scope="col">Description</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create" title="JavaScript/Reference/Global Objects/Object/Create">Object.create()</a></code></td>
   <td>使用指定的原型对象和属性. {{bug("492840")}}</td>
  </tr>
  <tr>
   <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty" title="JavaScript/Reference/Global Objects/Object/DefineProperty">Object.defineProperty()</a></code></td>
   <td><span style="background-color: rgba(212, 221, 228, 0.14902);">为对象添加给定的描述信息的</span>属性名.</td>
  </tr>
  <tr>
   <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties" title="JavaScript/Reference/Global Objects/Object/DefineProperties">Object.defineProperties()</a></code></td>
   <td><span style="background-color: rgba(212, 221, 228, 0.14902);">为对象添加多个给定的描述信息的</span><span style="background-color: rgba(212, 221, 228, 0.14902);">属性名</span>.</td>
  </tr>
  <tr>
   <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor" title="JavaScript/Reference/Global Objects/Object/GetOwnPropertyDescriptor">Object.getOwnPropertyDescriptor()</a></code></td>
   <td>返回对象的指定属性名的描述信息. {{bug("505587")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys" title="JavaScript/Reference/Global Objects/Object/keys"><code>Object.keys()</code></a></td>
   <td>返回由对象的所有可枚举属性组成的数组. {{bug("307791")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" title="JavaScript/Reference/Global Objects/Object/getOwnPropertyNames"><code>Object.getOwnPropertyNames()</code></a></td>
   <td><span style="background-color: rgba(212, 221, 228, 0.14902);">返回由对象的所有可枚举和不可枚举属性组成的数组</span>. {{bug("518663")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions" title="JavaScript/Reference/Global Objects/Object/preventExtensions"><code>Object.preventExtensions()</code></a></td>
   <td>防止对象进行任意的扩展. {{bug("492849")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible" title="JavaScript/Reference/Global Objects/Object/isExtensible"><code>Object.isExtensible()</code></a></td>
   <td>判断对象是否可以扩展. {{bug("492849")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal" title="JavaScript/Reference/Global Objects/Object/seal"><code>Object.seal()</code></a></td>
   <td>防止其他代码删除对象的属性. {{bug("492845")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed" title="JavaScript/Reference/Global Objects/Object/isSealed"><code>Object.isSealed()</code></a></td>
   <td>判断对象是否是密封<span style="background-color: rgba(212, 221, 228, 0.14902);">(即禁止删除属性)</span>的. {{bug("492845")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze" title="JavaScript/Reference/Global Objects/Object/freezed"><code>Object.freeze()</code></a></td>
   <td>冻结一个对象: 其他代码不能删除或修改任何属性. {{bug("492844")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen" title="JavaScript/Reference/Global Objects/Object/isFrozen"><code>Object.isFrozen()</code></a></td>
   <td>判断对象是否是冻结的. {{bug("492844")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray" title="JavaScript/Reference/Global Objects/Array/isArray"><code>Array.isArray()</code></a></td>
   <td>判断变量是否是数组. {{bug("510537")}}</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON" title="JavaScript/Reference/Global Objects/Date/toJSON"><code>Date.prototype.toJSON()</code></a></td>
   <td>返回一个Date对象用JSON格式化的字符串.</td>
  </tr>
  <tr>
   <td><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind" title="JavaScript/Reference/Global_Objects/Function/bind"><code>Function.prototype.bind()</code></a></td>
   <td><span style="background-color: rgba(212, 221, 228, 0.14902);">创建一个新函数,当这个函数被调用时,函数会使用提供的上下文环境(给定的字符序列) {{bug("429507")}}</span></td>
  </tr>
 </tbody>
</table>

<h3 id="ECMAScript5新特性">ECMAScript5新特性</h3>

<ul>
 <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/get" title="JavaScript/Reference/Operators/Special Operators/get Operator">get</a></code><code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/set" title="JavaScript/Reference/Operators/Special Operators/set Operator">set</a></code> 操作现在允许标识为数值或字符串. {{bug("520696")}}</li>
 <li><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply" title="JavaScript/Reference/Global Objects/Function/apply"><code>Function.apply()</code></a> 能接受任意的类数组的对象作为参数列表,而不是只支持真正数组.</li>
 <li><a href="/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode" title="JavaScript/Strict mode">支持严格 模式</a></li>
 <li><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString" title="JavaScript/Reference/Global Objects/Array/toString"><code>Array.toString()</code></a> 现在允许在非数组上使用,如果允许则会返回调用其 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join" title="JavaScript/Reference/Global Objects/Array/join"><code>join()</code></a> 方法,否则调用 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString" title="JavaScript/Reference/Global Objects/Object/toString"><code>toString()</code></a> 方法.</li>
</ul>

<h3 id="其他标准化的工作">其他标准化的工作</h3>

<p>删除一些定义getters和setters的非标准化语法; ECMAScript 5 定义的语法没有变化. 这些语法很难懂且很少被使用; 如果这个影响到你, 详细内容请看 <a class="external" href="http://whereswalden.com/2010/04/16/more-spidermonkey-changes-ancient-esoteric-very-rarely-used-syntax-for-creating-getters-and-setters-is-being-removed/" title="http://whereswalden.com/2010/04/16/more-spidermonkey-changes-ancient-esoteric-very-rarely-used-syntax-for-creating-getters-and-setters-is-being-removed/">这篇博客</a>.</p>

<h3 id="新对象">新对象</h3>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Object</th>
   <th scope="col">Description</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Proxy">Proxy</a></code></td>
   <td>提供创建对象和函数的代理,以在Javascript中支持元编程.</td>
  </tr>
 </tbody>
</table>

<h2 id="JavaScript_1.8.5中功能变化">JavaScript 1.8.5中功能变化</h2>

<ul>
 <li>ISO 8601 在Date中支持<code>: </code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date">Date</a> 对象的 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse">parse()</a> 方法现在支持简单的ISO 8601 格式化时间字符串.</li>
 <li>全局对象变为只读: 按照ECMAScript 5 标准,<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN" title="JavaScript/Reference/Global Objects/NaN"><code>NaN</code></a>, <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity" title="JavaScript/Reference/Global Objects/Infinity"><code>Infinity</code></a>, 和 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined" title="JavaScript/Reference/Global Objects/undefined"><code>undefined</code></a> 全局对象变为只读.</li>
 <li><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/Parent" title="JavaScript/Reference/Global Objects/Object/Parent"><code>obj.__parent__</code></a> and <code>obj.__count__</code> 过时. 部分原因如下:: <a class="external" href="http://whereswalden.com/2010/05/07/spidermonkey-change-du-jour-the-special-__parent__-property-has-been-removed/" title="http://whereswalden.com/2010/05/07/spidermonkey-change-du-jour-the-special-__parent__-property-has-been-removed/">SpiderMonkey change du jour: the special __parent__ property has been removed</a> {{bug("551529")}} &amp; {{bug("552560")}}.</li>
 <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse" title="Using native JSON">JSON.parse()</a>不再支持逗号结尾</code>.</li>
</ul>