diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects')
19 files changed, 0 insertions, 1993 deletions
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 ---- -<div>{{JSRef}}{{obsolete_header}}</div> - -<p><strong>Array.observe()</strong> 方法用于异步监视数组发生的变化,类似于针对对象的 {{jsxref("Object.observe()")}} 。当数组的值发生变化时,它按发生顺序提供了一个变化流。与 <code>Object.observe()</code> 类似,它由如下可接受的变化类型列表<code>["add"、"update"、"delete"、"splice"]</code>触发。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code>Array.observe(<var>arr</var>, <var>callback</var>)</code></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>arr</code></dt> - <dd>用于被监视的数组</dd> - <dt><code>callback</code></dt> - <dd>每当数组发生变化时,使用如下参数调用该函数: - <dl> - <dt><code>changes</code></dt> - <dd>用于表示变化的对象数组。每个变化对象的属性如下: - <ul> - <li><strong><code>name</code></strong>: 变化的属性名。</li> - <li><strong><code>object</code></strong>: 变化后的数组。</li> - <li><strong><code>type</code></strong>: 用于表示变化类型的字符串。<code>其取值为"add"、</code><code>"update"、</code><code>"delete"</code>或 <code>"splice"</code>之一。</li> - <li><strong><code>oldValue</code></strong>: 仅用于<code>"update"</code>和<code>"delete"类型。变化</code>之前的取值。</li> - <li><strong><code>index</code></strong>: <code>仅用于"splice"类型。</code>变化发生所在索引。</li> - <li><strong><code>removed</code></strong>: 仅用于<code>"splice"类型。</code>被删除元素组成的数组。</li> - <li><strong><code>addedCount</code></strong>: 仅用于<code>"splice"</code>类型。被添加的元素数量。</li> - </ul> - </dd> - </dl> - </dd> -</dl> - -<h2 id="描述">描述</h2> - -<p>每次 arr 发生任何变化时,回调函数将被调用,调用参数为所有变化按发生顺序组成的数组。</p> - -<div class="note"> -<p>通过Array方法如<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/pop"> Array.prototype.pop( )</a> 触发的变化将被报告成"<em>splice</em>"变化,长度不变但索引赋值发生变化的将被报告成"update"变化。</p> -</div> - -<h2 id="示例">示例</h2> - -<h3 id="Example_Logging_different_change_types">Example: Logging different change types</h3> - -<pre class="brush: js">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}] -</pre> - -<h2 id="Specifications" name="Specifications">标准规范</h2> - -<p><a href="https://github.com/arv/ecmascript-object-observe">Strawman proposal specification</a>.</p> - -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器支持</h2> - -<div> -<div> - - -<p>{{Compat("javascript.builtins.Array.observe")}}</p> -</div> -</div> - -<h2 id="See_also" name="See_also">相关内容</h2> - -<ul> - <li>{{jsxref("Array.unobserve()")}} {{experimental_inline}}</li> - <li>{{jsxref("Object.observe()")}} {{experimental_inline}}</li> - <li><a href="https://stackoverflow.com/q/29269057/778272">Under what condition would Array.observe's “add” event trigger?</a></li> -</ul> 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 ---- -<div>{{JSRef}} {{non-standard_header}}</div> - -<p>Array<strong>.unobserve()方法用来移除</strong>{{jsxref("Array.observe()")}}设置的所有观察者。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code>Array.unobserve(<var>arr</var>, <var>callback</var>)</code></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>arr</code></dt> - <dd>停止观察的数组。</dd> - <dt> </dt> - <dt><code>callback回调</code></dt> - <dd>需要停止的array <strong>arr</strong>每次改变都会调用的函数引用。</dd> -</dl> - -<h2 id="描述">描述</h2> - -<p><code>Array.unobserve()</code> 方法因为要移除观察者,所以应该在{{jsxref("Array.observe()")}}调用后调用。</p> - -<p>回调函数应该是一个函数的引用并且不能是匿名函数, 因为这个函数需要用来移除前面的观察者, 如果用匿名函数是没有用的,将不能移除任何观察者。</p> - -<h2 id="例子">例子</h2> - -<h3 id="停止观察一个数组">停止观察一个数组</h3> - -<pre class="brush: js">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</pre> - -<h3 id="使用匿名函数">使用匿名函数</h3> - -<pre class="brush: js">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 -</pre> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div> -<div> - - -<p>{{Compat("javascript.builtins.Array.unobserve")}}</p> -</div> -</div> - -<h2 id="相关内容">相关内容</h2> - -<ul> - <li>{{jsxref("Array.observe()")}} {{non-standard_inline}}</li> - <li>{{jsxref("Object.observe()")}} {{non-standard_inline}}</li> - <li>{{jsxref("Object.unobserve()")}} {{non-standard_inline}}</li> -</ul> 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 ---- -<div>{{JSRef}} {{SeeCompatTable}}</div> - -<p> 静态<code><strong>ArrayBuf</strong></code><strong>fer.transfer()</strong> 方法返回一个新的ArrayBuffer, 其内容取自oldBuffer的数据,并且根据 newByteLength 的大小来对数据进行截取或者以0扩展。 如果 newByteLength 未定义,则使用 oldBuffer 的byteLength。这个操作使得 oldBuffer 处于被移除的状态。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">ArrayBuffer.transfer(oldBuffer [, newByteLength]);</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>oldBuffer</code></dt> - <dd> 要转移的{{jsxref("ArrayBuffer")}}对象。</dd> - <dt>newByteLength</dt> - <dd>新 <code>ArrayBuffer</code> 对象的字节长度。</dd> -</dl> - -<h3 id="返回值">返回值</h3> - -<p>一个新的ArrayBuffer对象。</p> - -<h2 id="描述">描述</h2> - -<p><code>ArrayBuffer.transfer()</code>方法允许你增长和移除 <code>ArrayBuffer</code> 对象。不需复制就能增长一个ArrayBuffer的功能,对于大的缓冲区来说,有速度优势 (类似realloc) 。当释放底层内存时,移除ArrayBuffer的功能给开发者提供了显式控制。这避免了必须丢弃所有引用和等待垃圾回收。</p> - -<h2 id="示例">示例</h2> - -<pre class="brush: js">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 -</pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>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<font face="Consolas, Liberation Mono, Courier, monospace">()</font> 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.</p> - -<pre>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) - } - } - }; -}</pre> - -<h2 id="规范">规范</h2> - -<p>Not part of any current specification draft document, but <a href="https://esdiscuss.org/topic/sept-23-2014-meeting-notes">has been</a> <a href="https://gist.github.com/lukewagner/2735af7eea411e18cf20">proposed</a> for a future ECMA-262 edition.</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("javascript.builtins.ArrayBuffer.transfer")}}</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li><a href="/en-US/docs/Web/JavaScript/Typed_arrays" title="en/JavaScript typed arrays">JavaScript typed arrays</a></li> -</ul> 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 ---- -<div>{{JSRef}} {{non-standard_header}}</div> - -<p>非标准方法 <strong><code>toLocaleFormat()</code></strong> 按特定的格式将一个日期转换成一个字符串。 {{jsxref("Global_Objects/DateTimeFormat", "Intl.DateTimeFormat")}} 是符合标准的格式化日期的替代方法。另见更新的(newer)版本的 {{jsxref("Date.prototype.toLocaleDateString()")}}方法.</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code><var>dateObj</var>.toLocaleFormat(<var>formatString</var>)</code></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>formatString</code></dt> - <dd>与C语言中的 <a class="external" href="http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html"><code>strftime()</code></a> 方法的参数形式要求相同的格式字符串。</dd> -</dl> - -<h2 id="描述">描述</h2> - -<p><code>toLocaleFormat()</code> 方法通过格式化生成的日期或时间提供了更好的软件层面的控制(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.</p> - -<p>Extension and XULRunner developers should know that just loading the format string from a <code>.dtd</code> or <code>.properties</code> file using a <code>chrome://<em>somedomain</em>/locale/<em>somefile.ext</em></code> URI should be <strong>avoided</strong>, as the <code>.dtd</code>/<code>.properties</code> file and the <code>toLocaleFormat()</code> method does not not necessarily use the same locale, which could result in odd looking or even ambiguous or unreadable dates.</p> - -<p>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 <code>toLocale*</code> 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 <code>get*</code> methods of the {{jsxref("Global_Objects/Date", "Date")}} object instead of using this method.</p> - -<h2 id="示例">示例</h2> - -<h3 id="Using_toLocaleFormat()">Using <code>toLocaleFormat()</code></h3> - -<pre class="brush: js">var today = new Date(); -var date = today.toLocaleFormat('%A, %B %e, %Y'); // Bad example -</pre> - -<p>In this example, <code>toLocaleFormat()</code> 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.</p> - -<h2 id="腻子(Polyfill)">腻子(Polyfill)</h2> - -<p>When using the <a href="https://github.com/abritinthebay/datejs/wiki/Format-Specifiers">DateJS</a> library you can polyfill {{jsxref("Date.prototype.toLocaleDateString()")}} like this:</p> - -<pre class="brush: js">if (!Date.prototype.toLocaleFormat) { - (function() { - Date.prototype.toLocaleFormat = function(formatString) { - return this.format(formatString); - }; - }()); -}</pre> - -<h2 id="标准">标准</h2> - -<p>不属于任何标准。在JavaScript 1.6中被实现。</p> - -<h2 id="兼容性">兼容性</h2> - -<div> -<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> - -<p>{{Compat("javascript.builtins.Date.toLocaleFormat")}}</p> -</div> - -<h2 id="另见">另见</h2> - -<ul> - <li>{{jsxref("Global_Objects/DateTimeFormat", "Intl.DateTimeFormat")}}</li> - <li>{{jsxref("Date.prototype.toLocaleString()")}}</li> - <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li> - <li>{{jsxref("Date.prototype.toLocaleTimeString()")}}</li> -</ul> 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 ---- -<div> -<div>{{JSRef("Global_Objects", "Function")}} {{obsolete_header}}</div> -</div> - -<h2 id="Summary" name="Summary">概述</h2> - -<p>返回一个函数的形参数量.</p> - -<h2 id="Description" name="Description">描述</h2> - -<p class="note"><code>arity</code>是一个古老的已经没有浏览器支持的属性,你应该使用<code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Function/length" title="JavaScript/Reference/Global_Objects/Function/length">Function.prototype.length</a></code>属性来代替.</p> 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 ---- -<div>{{JSRef("Global_Objects", "Function")}} {{non-standard_header}}</div> - -<h2 id="概述">概述</h2> - -<p>判断一个函数是否是一个<a href="/zh-cn/JavaScript/Guide/Iterators_and_Generators#Generators.3a_a_better_way_to_build_Iterators" title="zh-cn/Core JavaScript 1.5 Guide/Iterators and Generators#Generators.3a a better way to build Iterators">生成器</a>.</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code><var>fun</var>.isGenerator()</code></pre> - -<h2 id="描述">描述</h2> - -<p>该方法用来判断一个函数是否是一个<a href="/zh-cn/JavaScript/Guide/Iterators_and_Generators#Generators.3a_a_better_way_to_build_Iterators" title="zh-cn/Core JavaScript 1.5 Guide/Iterators and Generators#Generators.3a a better way to build Iterators">生成器</a>.</p> - -<h2 id="例子">例子</h2> - -<pre class="brush: js">function f() {} -function* g() { - yield 42; -} -console.log("f.isGenerator() = " + f.isGenerator()); -console.log("g.isGenerator() = " + g.isGenerator()); -</pre> - -<p>上面代码的输出结果为</p> - -<pre>f.isGenerator() = false -g.isGenerator() = true -</pre> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li><a href="/zh-cn/JavaScript/Guide/Iterators_and_Generators" title="zh-cn/Core JavaScript 1.5 Guide/Iterators and Generators">迭代器和生成器</a></li> -</ul> 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 ---- -<div>{{jsSidebar("Objects")}}</div> - -<div class="warning"><strong>非标准。</strong> <code><strong>Iterator</strong></code> 函数是一个 SpiderMonkey 专有特性,并且会在某一时刻被删除。为将来使用的话,请考虑使用 {{jsxref("Statements/for...of", "for...of")}} 循环和 <a href="/zh-CN/docs/Web/JavaScript/Guide/The_Iterator_protocol">迭代协议</a>。</div> - -<p><code><strong>Iterator</strong></code> 函数返回一个对象,它实现了遗留的迭代协议,并且迭代了一个对象的可枚举属性。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">Iterator(<var>object</var>, [keyOnly])</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>object</code></dt> - <dd>要迭代属性的对象。</dd> - <dt><code>keyOnly</code></dt> - <dd> 如果<code>keyOnly</code>是真值,<code>Iterator.prototype.next</code> <code>只返回property_name</code> 。</dd> -</dl> - -<h2 id="描述">描述</h2> - -<p><code>返回迭代了object的Iterator</code> 实例。如果<code>keyOnly</code>为假值,则<code>Iterator</code> 实例返回每次迭代而生成的 <code>[property_name, property_value]</code> 数组,否则,如果<code>keyOnly</code>是真值,则它返回每次迭代的 <code>property_name</code>。如果<code>object</code> 是 <code>Iterator</code> 实例或 {{jsxref("Generator")}} 实例 ,则它返回 <code>object</code> 自身。</p> - -<h2 id="属性">属性</h2> - -<dl> - <dt><code><strong>Iterator.prototype[@@iterator]</strong></code></dt> - <dd>返回一个函数,它返回符合{{jsxref("Iteration_protocols", "迭代协议", "", 1)}}的迭代对象。</dd> -</dl> - -<h2 id="方法">方法</h2> - -<dl> - <dt><code><strong>Iterator.prototype.next</strong></code></dt> - <dd>返回<code>[property_name, property_value]</code> 格式或<code>property_name</code> 的下一项。 如果没有更多项,抛出 <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/StopIteration">StopIteration</a></code> 。</dd> -</dl> - -<h2 id="示例">示例</h2> - -<h3 id="迭代一个对象的属性">迭代一个对象的属性</h3> - -<pre class="brush: js">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 -</pre> - -<h3 id="使用遗留的解构for-in迭代对象的属性">使用遗留的<code>解构for-in迭代对象的属性</code></h3> - -<pre class="brush: js">var a = { - x: 10, - y: 20, -}; - -for (var [name, value] in Iterator(a)) { - console.log(name, value); // x 10 - // y 20 -} -</pre> - -<h3 id="使用for-of迭代">使用<code>for-of迭代</code></h3> - -<pre class="brush: js">var a = { - x: 10, - y: 20, -}; - -for (var [name, value] of Iterator(a)) { // @@iterator is used - console.log(name, value); // x 10 - // y 20 -} -</pre> - -<h3 id="迭代属性名">迭代属性名</h3> - -<pre class="brush: js">var a = { - x: 10, - y: 20, -}; - -for (var name in Iterator(a, true)) { - console.log(name); // x - // y -} -</pre> - -<h3 id="传入_Generator_实例">传入 Generator 实例</h3> - -<pre class="brush: js">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 -} -</pre> - -<h3 id="传入_Iterator_实例">传入 Iterator 实例</h3> - -<pre class="brush: js">var a = { - x: 10, - y: 20, -}; - -var i = Iterator(a); - -console.log(i == Iterator(i)); // true -</pre> - -<h2 id="规范">规范</h2> - -<p>非标准。不是目前任何标准文档的一部分。</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<p>{{CompatibilityTable}}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li><a href="/zh-CN/docs/JavaScript/Guide/Iterators_and_Generators" title="/en-US/docs/JavaScript/Guide/Iterators_and_Generators">Iterators and Generators</a></li> - <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/StopIteration">StopIteration</a></code><br> - </li> -</ul> 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 ---- -<div>{{JSRef("Global_Objects", "Number")}} {{obsolete_header("33")}} {{non-standard_header}}</div> - -<h2 id="Summary" name="Summary">概览</h2> - -<p><strong><code>Number.toInteger()</code></strong> 用来将参数转换成整数,但该方法的实现已被移除.</p> - -<p>如果参数是 {{jsxref("Global_Objects/NaN", "NaN")}}, {{jsxref("Global_Objects/null", "null")}} 或 {{jsxref("Global_Objects/undefined", "undefined")}}, 会返回0 . 如果参数值是true返回1,false的话返回<span style="line-height: 19.0909080505371px;">0</span>.</p> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="syntaxbox"><code>Number.toInteger(<var>number</var>)</code></pre> - -<h3 id="Parameters" name="Parameters">参数</h3> - -<dl> - <dt><code>number</code></dt> - <dd>将被转换成整数的参数.</dd> -</dl> - -<h2 id="Examples" name="Examples">示例</h2> - -<h3 id="Example:_Using_toInteger" name="Example:_Using_toInteger">例子: 使用 <code>toInteger()方法</code></h3> - -<pre class="brush: js">Number.toInteger(0.1); // 0 -Number.toInteger(1); // 1 -Number.toInteger(Math.PI); // 3 -Number.toInteger(null); // 0 -</pre> - -<h2 id="Specifications" name="Specifications">Specifications</h2> - -<ul> - <li><code>Number.toInteger()</code> 是<span style="line-height: 19.0909080505371px;">ECMAScript 6 起草的一部分</span>, 但在2013-8-23的Draft Rev 17 中被移除 .</li> -</ul> - -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>Firefox 16 to 32</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>Firefox 16 to 32</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See_also" name="See_also">See also</h2> - -<ul> - <li>归属于 {{jsxref("Global_Objects/Number", "Number")}} 对象.</li> -</ul> 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 ---- -<div>{{JSRef}} {{obsolete_header("2")}}</div> - -<p> <strong><code>__count__</code></strong> 属性曾经用来存放对象的可枚举的属性的个数,但是已经被废除。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code><var>obj</var>.__count__</code></pre> - -<h2 id="示例">示例</h2> - -<pre class="brush: js">{ 1: 1 }.__count__ // 1 -[].__count__ // 0 -[1].__count__ // 1 -[1, /* hole */, 2, 3].__count__ // 3 -</pre> - -<h2 id="详细说明">详细说明</h2> - -<p>无需详细说明</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="更多请参看">更多请参看</h2> - -<ul> - <li><a class="external" href="http://whereswalden.com/2010/04/06/more-changes-coming-to-spidermonkey-the-magical-__count__-property-of-objects-is-being-removed/">[Blog post] More changes coming to SpiderMonkey: the magical __count__ property is being removed</a></li> -</ul> 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 ---- -<div>{{JSRef}} {{obsolete_header}}</div> - -<p><code><strong>Object.eval()</strong></code> 方法用于在对象的上下文中对 JavaScript 代码字符串求值,但该方法已被移除。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code><var>obj</var>.eval(<var>string</var>)</code></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>string</code></dt> - <dd>包含任意 JavaScript 表达式、语句或一组语句的字符串。表达式中可包含已有对象的变量与属性。</dd> -</dl> - -<h2 id="描述">描述</h2> - -<p><code>eval</code> 方法已从对象方法中移除。可使用全局 {{jsxref("Global_Objects/eval", "eval()")}} 函数替代该方法。</p> - -<h2 id="规范">规范</h2> - -<p>暂无规范</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{jsxref("Global_Objects/eval", "eval()")}}</li> -</ul> 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 ---- -<div>{{JSRef}} {{obsolete_header}}</div> - -<p><strong><code>Object.getNotifer()</code></strong> 方法用于创建可人工触发 change 事件的对象,但该方法在浏览器中已被废弃。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">Object.getNotifier(<em>obj</em>)</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>obj</code></dt> - <dd>获取通知的对象。</dd> -</dl> - -<h3 id="返回值">返回值</h3> - -<p>与传入对象相关联的通知对象。</p> - -<h2 id="描述">描述</h2> - -<p><code><font face="Open Sans, Arial, sans-serif">通知对象可触发 </font>Object.observe() 所观察到的人工变动。</code></p> - -<h2 id="规范">规范</h2> - -<p><a href="https://github.com/arv/ecmascript-object-observe">Strawman proposal specification.</a></p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome("36")}} [1]</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome("36")}} [1]</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Deprecated in Chrome 49.</p> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{jsxref("Object.observe()")}} {{obsolete_inline}}</li> - <li>{{jsxref("Object.unobserve()")}} {{obsolete_inline}}</li> - <li>{{jsxref("Array.observe()")}} {{obsolete_inline}}</li> -</ul> 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 ---- -<div>{{JSRef}} {{obsolete_header}}</div> - -<p><strong><code>__noSuchMethod__</code></strong> 属性曾经是指当调用某个对象里不存在的方法时即将被执行的函数,但是现在这个函数已经不可用。</p> - -<p><code><font face="Open Sans, Arial, sans-serif">在</font><strong>__noSuchMethod__</strong></code> 属性被移除之后,ECMAScript 2015 (ES6) 规范转而采用 {{jsxref("Proxy")}} 对象, 可以实现下面的效果(以及更多)。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code><var>obj</var>.__noSuchMethod__ = <var>fun</var></code></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>fun</code></dt> - <dd>函数形式如下:</dd> - <dd> - <pre class="brush: js"><code>function (<var>id</var>, <var>args</var>) { . . . }</code></pre> - - <dl> - <dt><code>id</code></dt> - <dd>调用的不存在的方法名</dd> - <dt><code>args</code></dt> - <dd>传递给该方法的参数数组</dd> - </dl> - </dd> -</dl> - -<h2 id="描述">描述</h2> - -<p>默认情况喜爱,试图调用对象上不存在的方法其结果是在{{jsxref("TypeError")}}上抛出异常,这种行为可以在</p> - -<p>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 <code>__noSuchMethod__</code> 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 <a href="/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments" title="JavaScript/Reference/Functions/arguments">arguments object</a>.</p> - -<p>If this method cannot be called, either as if <code>undefined</code> by default, if deleted, or if manually set to a non-function, the JavaScript engine will revert to throwing <code>TypeError</code>s.</p> - -<h2 id="Examples">Examples</h2> - -<h3 id="Simple_test_of___noSuchMethod__">Simple test of <code>__noSuchMethod__</code></h3> - -<pre class="brush: js">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 () -</pre> - -<h3 id="Using___noSuchMethod___to_simulate_multiple_inheritance">Using <code>__noSuchMethod__</code> to simulate multiple inheritance</h3> - -<p>An example of code that implements a primitive form of multiple inheritance is shown below.</p> - -<pre class="brush: js">// 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); -} -</pre> - -<p>An example of using this idea is shown below.</p> - -<pre class="brush: js">// 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 -</pre> - -<h2 id="Specifications">Specifications</h2> - -<p>Not part of any specifications. This feature has been removed, see {{bug(683218)}}.</p> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}} [1]</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}} [1]</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] This feature was implemented until version 43.</p> 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 ---- -<div>{{JSRef}} {{obsolete_header}}</div> - -<h2 id="概述">概述</h2> - -<p><strong><code>Object.observe()</code></strong> 方法用于异步地监视一个对象的修改。当对象属性被修改时,方法的回调函数会提供一个有序的修改流。然而,这个接口已经被废弃并从各浏览器中移除。你可以使用更通用的 {{jsxref("Proxy")}} 对象替代。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code>Object.observe(<var>obj</var>, <var>callback</var></code>[, <var>acceptList</var>])</pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>obj</code></dt> - <dd>被监控的对象.</dd> - <dt><code>callback</code></dt> - <dd>当对象被修改时触发的回调函数,其参数为: - <dl> - <dt><code>changes</code></dt> - <dd>一个数组,其中包含的每一个对象代表一个修改行为。每个修改行为的对象包含: - <ul> - <li><strong><code>name</code></strong>: 被修改的属性名称<span style="font-family: consolas,monaco,andale mono,monospace;">。</span></li> - <li><strong><code>object</code></strong>: 修改后该对象的值<span style="font-family: consolas,monaco,andale mono,monospace;">。</span></li> - <li><strong><code>type</code></strong>: 表示对该对象做了何种类型的修改,可能的值为<code>"add"</code>, <code>"update"</code>, or <code>"delete"</code><span style="font-family: consolas,monaco,andale mono,monospace;">。</span></li> - <li><strong><code>oldValue</code></strong>: 对象修改前的值。该值只在<code>"update"<font face="Open Sans, sans-serif">与</font></code><code>"delete"有效。</code></li> - <li> </li> - </ul> - </dd> - <dt><font face="Consolas">acceptList</font></dt> - <dd>在给定对象上给定回调中要监视的变化类型列表。如果省略, <code><font face="Courier New">["add", "update", "delete", "reconfigure", "setPrototype", "preventExtensions"]</font></code> 将会被使用。</dd> - </dl> - </dd> -</dl> - -<h2 id="描述">描述</h2> - -<p><code style="font-style: normal;">callback</code> 函数会在<code>对象被改变时被调用,其参数为一个包含所有修改信息的有序的数组对象。</code></p> - -<h2 id="例子">例子</h2> - -<h3 id="例子_打印出三种不同操作类型的日志">例子: 打印出三种不同操作类型的日志</h3> - -<pre class="brush: js">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}] -</pre> - -<h3 id="例子_数据绑定">例子: 数据绑定</h3> - -<pre class="brush: js">// 一个数据模型 -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(); - } - }); -}); -</pre> - -<h2 id="Specifications" name="Specifications">规范</h2> - -<p><a href="https://github.com/arv/ecmascript-object-observe">Strawman proposal for ECMAScript 7</a>.</p> - -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome("36")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome("36")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See_also" name="See_also">相关链接</h2> - -<ul> - <li>{{jsxref("Object.unobserve()")}} {{experimental_inline}}</li> - <li>{{jsxref("Array.observe()")}} {{experimental_inline}}</li> -</ul> 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 ---- -<div>{{JSRef}}{{Non-standard_Header}}{{Obsolete_Header("gecko2")}}</div> - -<p>The <strong><code>__parent__</code></strong> property used to point to an object's context, but it has been removed.</p> - -<p>指向一个对象的上下文.</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><var>obj</var>.__parent__</pre> - -<h2 id="描述">描述</h2> - -<p>对于最顶层对象来说,这个属性的值就是全局对象 window。</p> - -<h2 id="规范">规范</h2> - -<p>不属于任何规范。</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("javascript.builtins.Object.parent")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li><a class="external" href="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></li> - <li><a href="/zh-CN/docs/Components.utils.getGlobalForObject">Components.utils.getGlobalForObject</a></li> - <li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/Proto">__proto__</a></li> -</ul> 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 ---- -<div>{{JSRef}} {{non-standard_header}}</div> - -<p><strong>Object.unobserve()</strong> 是用来移除通过 {{jsxref("Object.observe()")}}设置的观察者的方法。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code>Object.unobserve(<var>obj</var>, <var>callback</var>)</code></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>obj</code></dt> - <dd>需要停止观察的对象。</dd> - <dt><code>callback</code></dt> - <dd>通过 observer 给 <strong>obj </strong>对象设置的回调函数.</dd> -</dl> - -<h2 id="描述">描述</h2> - -<p><code>Object.unobserve()</code> 用来在 {{jsxref("Object.observe()")}} 被调用以后,从对象上移除一个观察者。</p> - -<p>这个回调函数必须是一个函数的引用,而不能是一个匿名函数。因为这个引用将被用来移除之前设置的观察者方法。 给 <strong>Object.unobserve() </strong>传入匿名函数作为回调是不起作用的, 它不能移除任何观察者方法。</p> - -<h2 id="例子">例子</h2> - -<h3 id="观察一个对象">观察一个对象</h3> - -<pre class="brush: js">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; -// 回调函数不会被调用</pre> - -<h3 id="使用匿名函数">使用匿名函数</h3> - -<pre class="brush: js">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'}] -// 回调函数将会被调用 -</pre> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome("36")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome("36")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{jsxref("Object.observe()")}} {{non-standard_inline}}</li> - <li>{{jsxref("Array.observe()")}} {{non-standard_inline}}</li> - <li>{{jsxref("Array.unobserve()")}} {{non-standard_inline}}</li> -</ul> 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 ---- -<div>{{JSRef}}</div> - -<div class="warning"> -<p><strong>警告 :</strong> 请尽量避免使用 unwatch() 和 {{jsxref("Object.prototype.watch", "watch()")}} . 这两个方法仅在 Gecko 中实现 , 并且他们过去主要作调试用. 另外, 使用 watchpoints 对性能有一系列的副面影响 ,特别是当使用全局对象,如 <code>window</code>. 你应该使用 <a href="/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters">setters and getters</a> 或 proxies 来替代. 查阅 {{anch("Browser compatibility")}} 以获取更多信息.</p> -</div> - -<p><code><strong>unwatch()</strong></code> 删除一个 {{jsxref("Object.prototype.watch", "watch()")}} 设置的 watchpoint.</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><code><var>obj</var>.unwatch(<var>prop</var>)</code></pre> - -<h3 id="参数">参数</h3> - -<dl> - <dt><code>prop</code></dt> - <dd>想要停止监视的对象的属性名</dd> -</dl> - -<h2 id="描述">描述</h2> - -<p>JavaScript调试器具有类似的功能,以及其他调试选项。有关调试器的信息 <a href="/en-US/docs/Venkman">Venkman</a>.</p> - -<p>默认地, 这个方法 被每一个 {{jsxref("Object")}} 的子类继承 </p> - -<div class="note"> -<p><strong>Note:</strong> The reason for <code>unwatch()</code> to take the property name <em>prop</em> as its only parameter is due to the "single handler allowing" behavior of the {{jsxref("Object.watch", "watch()")}} method.</p> -</div> - -<h2 id="例子">例子</h2> - -<p>See {{jsxref("Object.watch", "watch()")}}.</p> - -<h2 id="说明">说明</h2> - -<p>Not part of any specifications. Implemented in JavaScript 1.2.</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="Compatibility_notes">Compatibility notes</h2> - -<ul> - <li>从 Firefox 23 ({{bug(903332)}}) 开始, 在 {{domxref("Document")}} 对象上调用 <code>unwatch()</code> 抛出 {{jsxref("TypeError")}} . This regression has been fixed with Firefox 27.</li> -</ul> - -<h2 id="相关链接">相关链接</h2> - -<ul> - <li>{{jsxref("Object.watch()")}}</li> -</ul> 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 ---- -<p>{{JSRef}}</p> - -<div class="warning"> -<p><strong>警告:</strong> 通常来讲,你应该尽量避免使用 <code>watch()</code>和 {{jsxref("Object.prototype.unwatch", "unwatch()")}} 这两个方法。因为只有 Gecko 实现了这两个方法,并且它们主要是为了在调试方便。另外,使用 watchpoint 对性能有严重的负面影响,在全局对象(如 window)上使用时尤其如此。你可以使用 <a href="/zh-cn/JavaScript/Guide/Working_with_Objects#Defining_getters_and_setters" title="https://developer.mozilla.org/zh-cn/Core_JavaScript_1.5_Guide/Working_with_Objects#Defining_getters_and_setters">setters and getters</a> 或者 proxy 代替。参见 {{ anch("Compatibility") }} 了解详情。</p> -</div> - -<p><code><strong>watch() </strong></code>方法会监视属性是否被赋值并在赋值时运行相关函数。</p> - -<h2 id="Summary" name="Summary">语法</h2> - -<pre class="syntaxbox"><em>obj</em>.watch(<em>prop</em>, <em>handler</em>)</pre> - -<h3 id="Parameters" name="Parameters">参数</h3> - -<dl> - <dt><code>prop</code></dt> - <dd>想要监视值是否发生变化的指定对象的某个属性的属性名称</dd> -</dl> - -<dl> - <dt><code>handler</code></dt> - <dd>当指定的属性发生变化时执行的回调函数</dd> -</dl> - -<h3 id="返回值">返回值</h3> - -<p>{{jsxref("undefined")}}.</p> - -<h2 id="Description" name="Description">描述</h2> - -<p>监视对指定对象的名为 <code>prop</code> 属性的赋值操作,只要 <code>prop</code> 属性被赋值,便调用 <code>handler(prop, oldval, newval)</code> 回调函数,并将函数返回值保存到该属性。 通过返回修改的新值(或者返回旧值),一个监视点可以过滤(或使之为 null )赋值。</p> - -<p>如果你删除某个设置监视点的属性,该监视点并不会消失。如果你之后重新创建这个属性,监视点仍然有效。</p> - -<p>要移除某个监视点,使用 <code><a href="/zh-cn/JavaScript/Reference/Global_Objects/Object/unwatch" title="zh-cn/JavaScript/Reference/Global_Objects/Object/unwatch">unwatch()</a></code> 方法。默认所有 <code>Object</code> 的后代都将继承 <code>watch</code> 方法。</p> - -<p>JavaScript 调试器有与之相似的机制以及其它调试选项。需要更多有关调试器的信息,请查阅 <a href="/zh-cn/Venkman" title="zh-cn/Venkman">Venkman</a>。</p> - -<p>对于 Firefox,<code>handler</code> 只会被脚本内的赋值操作激活,并不包括本地代码。举个例子,如果用户点击一个指向当前文档内的某个锚点, <code>window.watch('location', myHandler)</code> 不会回调 <code>myHandler</code> ,但 <code>window.location += '#myAnchor'</code> 将触发回调 <code>myHandler</code>。</p> - -<div class="note"><strong>注意:</strong> 对一个对象的指定属性调用 <code>watch()</code> 将覆盖先前关联的 handler。</div> - -<h2 id="Examples" name="Examples">例子</h2> - -<h3 id="Example_Using_watch_and_unwatch" name="Example:_Using_watch_and_unwatch">使用 <code>watch</code> 和 <code>unwatch</code></h3> - -<pre class="brush: js">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; -</pre> - -<p>上面的代码显示结果如下:</p> - -<pre class="eval">o.p 由 1 变为 2 -o.p 由 2 变为 3 -o.p 由 undefined 变为 4 -</pre> - -<h3 id="Example_Using_watch_to_validate_an_object.27s_properties" name="Example:_Using_watch_to_validate_an_object.27s_properties">使用 <code>watch</code> 来验证一个对象的属性</h3> - -<p>你可以使用 <code>watch</code> 来检测一个对象的属性赋值是否是合法的.下例演示了如何确保每个人始终具有一个合法的名字和0 到 200之间的年龄.</p> - -<pre class="brush: js">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); -} -</pre> - -<p>上面的代码显示结果如下:</p> - -<pre class="eval">Will, 29 -RangeError: 不合法的名字 Will, 29 -RangeError: 不合法的年龄 Will, 29 -</pre> - -<h2 id="Specifications">Specifications</h2> - -<p>不是任何规范的一部分。从 JavaScript 1.2 开始实现。</p> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="兼容性提示">兼容性提示</h2> - -<ul> - <li>此 <a href="https://gist.github.com/384583">Polyfill</a> 为所有 ES5 兼容浏览器提供 <code>watch</code> 支持。</li> - <li>使用 {{jsxref("Proxy")}} 允许你更加深度地调整属性服务机制</li> - <li>从 Firefox 23 开始,在 {{domxref("Document")}} 对象上调用 <code>watch()</code> 将抛出 {{jsxref("TypeError")}} 错误。这个回归问题已经在 Firefox 27 修复。</li> -</ul> - -<h2 id="See_Also" name="See_Also">相关链接</h2> - -<ul> - <li>{{jsxref("Object.unwatch()")}}</li> - <li>{{jsxref("Object.observe()")}} {{obsolete_inline}}</li> -</ul> 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 ---- -<p>The goal of <strong><code>ParallelArray</code></strong> was to enable data-parallelism in web applications. The higher-order functions available on <code>ParallelArray</code> 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 <a href="http://smallcultfollowing.com/babysteps/blog/2013/04/30/parallelizable-javascript-subset/">parallelizable subset of JS that Firefox supports</a>.</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox">new ParallelArray() -new ParallelArray([element0, element1, ...]) -new ParallelArray(arrayLength, elementalFunction)</pre> - -<h2 id="ParallelArray_instances"><code>ParallelArray</code> instances</h2> - -<h3 id="属性">属性</h3> - -<dl> - <dt>length</dt> - <dd>Reflects the number of elements in the <code>ParallelArray</code>.</dd> -</dl> - -<h3 id="方法">方法</h3> - -<dl> - <dt>map</dt> - <dt>reduce</dt> - <dt>scan</dt> - <dt>scatter</dt> - <dt>filter</dt> - <dt>flatten</dt> - <dt>partition</dt> - <dt>get</dt> -</dl> - -<h2 id="示例">示例</h2> - -<h3 id="Using_map_in_parallel">Using <code>map</code> in parallel</h3> - -<pre class="brush: js">var p = new ParallelArray([0, 1, 2, 3, 4]); -var m = p.map(function (v) { - return v + 1; -});</pre> - -<h2 id="参见">参见</h2> - -<ul> - <li><a href="http://wiki.ecmascript.org/doku.php?id=strawman:data_parallelism">Ecmascript ParallelArray strawman</a></li> -</ul> 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 ---- -<div>{{obsolete_header("37")}}</div> - -<div>{{JSRef("Global_Objects", "String")}}{{Non-standard_header}}</div> - -<h2 id="Summary" name="Summary">概述</h2> - -<p>将字符串中包含的特殊字符进行转义(反斜杠),然后在字符串两边各加上一个双引号(<code>"</code>)并返回,并不修改原字符串.</p> - -<h2 id="Syntax" name="Syntax">语法</h2> - -<pre class="syntaxbox"><code><em>str</em>.quote()</code></pre> - -<h2 id="Examples" name="Examples">示例</h2> - -<table class="fullwidth-table"> - <thead> - <tr> - <th class="header" scope="col"><code>str</code></th> - <th class="header" scope="col"><code>str.quote()</code></th> - <th class="header" scope="col"><code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/eval" title="JavaScript/Reference/Global_Objects/eval">eval</a>(str.quote())</code></th> - </tr> - </thead> - <tbody> - <tr> - <td><code>Hello world!</code></td> - <td><code>"Hello world!"</code></td> - <td><code>Hello world!</code></td> - </tr> - <tr> - <td><code>Hello<br> - world!</code></td> - <td><code>"Hello\n\tworld!"</code></td> - <td><code>Hello<br> - world!</code></td> - </tr> - <tr> - <td><code>" \ — '</code></td> - <td><code>"\" \\ \u2014 '"</code></td> - <td><code>" \ — '</code></td> - </tr> - </tbody> -</table> - -<h2 id="Specifications" name="Specifications">规范</h2> - -<p>不在任何规范中。实现于 JavaScript 1.3.</p> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="See_also" name="See_also">相关链接</h2> - -<ul> - <li><code><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/JSON/stringify" title="JavaScript/Reference/Global_Objects/JSON/stringify">JSON.stringify</a></code></li> -</ul> |