aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html
blob: ce514451d92ddb2f77a431d6933064a6b0445b2e (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
---
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>{{js_property_attributes(0,0,0)}}</div>

<h2 id="示例">示例</h2>

<p>[Symbol.split]指向‘aba’.split(/a/)</p>

<pre class="brush: js">/a/[Symbol.split]('aba',3)</pre>

<p>"dayinlove".split(exp)调用[Symbol.split](str)处理,并把实参"dayinlove"传给形参str</p>

<pre class="brush: js">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>

{{Compat}}

<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>