2019-04-21 11:50:48 +08:00

124 lines
5.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<article id="wikiArticle">
<div></div>
<p><code><strong>Symbol.split</strong></code> 指向 一个正则表达式的索引处分割字符串的方法。 这个方法通过 <a href="Reference/Global_Objects/String/split" title="split() 方法使用指定的分隔符字符串将一个String对象分割成字符串数组以将字符串分隔为子字符串以确定每个拆分的位置。"><code>String.prototype.split()</code></a> 调用。</p>
<p>详情请参阅<a href="Reference/Global_Objects/RegExp/@@split" title="[@@split]() 方法切割 String 对象为一个其子字符串的数组 。"><code>RegExp.prototype[@@split]()</code></a><a href="Reference/Global_Objects/String/split" title="split() 方法使用指定的分隔符字符串将一个String对象分割成字符串数组以将字符串分隔为子字符串以确定每个拆分的位置。"><code>String.prototype.split()</code></a>.</p>
<div><table class="standard-table">
<thead>
<tr>
<th class="header" colspan="2"><code>Symbol.split</code> 属性的属性特性:</th>
</tr>
</thead>
<tbody>
<tr>
<td>writable</td>
<td>false</td>
</tr>
<tr>
<td>enumerable</td>
<td>false</td>
</tr>
<tr>
<td>configurable</td>
<td>false</td>
</tr>
</tbody>
</table></div>
<h2 id="示例">示例</h2>
<p>[Symbol.split]指向aba.split(/a/)</p>
<pre><code class="language-javascript">/a/[Symbol.split]('aba',3)</code></pre>
<p>"dayinlove".split(exp)调用[Symbol.split](str)处理,并把实参"dayinlove"传给形参str</p>
<pre><code class="language-javascript">var exp = {
pat:'in',
[Symbol.split](str) {
return str.split(this.pat);
}
}
"dayinlove".split(exp);
//["day", "love"]</code></pre>
<h2 id="技术标准">技术标准</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">文档</th>
<th scope="col">状态</th>
<th scope="col">备注</th>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-symbol.split" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Symbol.split</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td>初始定义.</td>
</tr>
<tr>
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-symbol.split" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">Symbol.split</small></a></td>
<td><span class="spec-Draft">Draft</span></td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p></p><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div><p></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>50</td>
<td><a href="/en-US/Firefox/Releases/49" title="Released on 2016-09-13.">49</a> (49)</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></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><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td>49.0 (49)</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="参阅">参阅</h2>
<ul>
<li><a href="Reference/Global_Objects/Symbol/match" title="Symbol.match 指定了匹配的是正则表达式而不是字符串。String.prototype.match() 方法会调用此函数。"><code>Symbol.match</code></a></li>
<li><a href="Reference/Global_Objects/Symbol/replace" title="Symbol.replace 这个属性指定了当一个字符串替换所匹配字符串时所调用的方法。String.prototype.replace() 方法会调用此方法。"><code>Symbol.replace</code></a></li>
<li><a href="Reference/Global_Objects/Symbol/search" title="Symbol.search 指定了一个搜索方法这个方法接受用户输入的正则表达式返回该正则表达式在字符串中匹配到的下标这个方法由以下的方法来调用 String.prototype.search()。"><code>Symbol.search</code></a></li>
<li><a href="Reference/Global_Objects/RegExp/@@split" title="[@@split]() 方法切割 String 对象为一个其子字符串的数组 。"><code>RegExp.prototype[@@split]()</code></a></li>
</ul>
</article>