Symbol.split

Symbol.split 指向 一个正则表达式的索引处分割字符串的方法。 这个方法通过 String.prototype.split() 调用。

详情请参阅String.prototype.split().

Symbol.split 属性的属性特性:
writable false
enumerable false
configurable false

示例

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

/a/[Symbol.split]('aba',3)

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

var exp =  {
        pat:'in',
        [Symbol.split](str) {
          return str.split(this.pat);
          }
    }

    "dayinlove".split(exp); 
//["day", "love"]

技术标准

文档 状态 备注
ECMAScript 2015 (6th Edition, ECMA-262)
Symbol.split
Standard 初始定义.
ECMAScript Latest Draft (ECMA-262)
Symbol.split
Draft  

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 50 49 (49) 未实现 未实现 未实现
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 未实现 49.0 (49) 未实现 未实现 未实现

参阅