diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html new file mode 100644 index 0000000000..53b98d57cd --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html @@ -0,0 +1,117 @@ +--- +title: Symbol.split +slug: Web/JavaScript/Reference/Global_Objects/Symbol/split +translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/split +--- +<div>{{JSRef}}</div> + +<p><code><strong>Symbol.split</strong></code> 指向 一个正则表达式的索引处分割字符串的方法。 这个方法通过 {{jsxref("String.prototype.split()")}} 调用。</p> + +<p>详情请参阅{{jsxref("RegExp.@@split", "RegExp.prototype[@@split]()")}} 和{{jsxref("String.prototype.split()")}}.</p> + +<div>{{EmbedInteractiveExample("pages/js/symbol-split.html")}}</div> + +<div class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</div> + +<div>{{js_property_attributes(0,0,0)}}</div> + +<h2 id="示例">示例</h2> + +<p>[Symbol.split]指向‘aba’.split(/a/)</p> + +<pre class="brush: js notranslate">/a/[Symbol.split]('aba',3)</pre> + +<p>"dayinlove".split(exp)调用[Symbol.split](str)处理,并把实参"dayinlove"传给形参str</p> + +<pre class="brush: js notranslate">var exp = { + pat:'in', + [Symbol.split](str) { + return str.split(this.pat); + } + } + + "dayinlove".split(exp); +//["day", "love"]</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>{{SpecName('ES6', '#sec-symbol.split', 'Symbol.split')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>初始定义.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-symbol.split', 'Symbol.split')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<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>{{CompatChrome(50)}}</td> + <td>{{ CompatGeckoDesktop(49) }}</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>{{ CompatGeckoMobile(49) }}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="参阅">参阅</h2> + +<ul> + <li>{{jsxref("Symbol.match")}}</li> + <li>{{jsxref("Symbol.replace")}}</li> + <li>{{jsxref("Symbol.search")}}</li> + <li>{{jsxref("RegExp.@@split", "RegExp.prototype[@@split]()")}}</li> +</ul> |