Symbol.split

Symbol.split 정적 데이터 속성은 잘 알려진 심볼 @@split을 나타냅니다. String.prototype.split() 메서드는 현재 객체와 일치하는 인덱스에서 문자열을 분할하는 메서드의 첫 번째 인수에서 이 심볼을 찾습니다.

보다 상세한 내용은 RegExp.prototype[@@split]() (en-US)String.prototype.split()를 참조하시기 바랍니다.

시도해보기

잘 알려진 심볼 @@split.

Property attributes of Symbol.split
Writable 불가능
Enumerable 불가능
Configurable 불가능

예제

사용자 정의 역분할

js
class ReverseSplit {
  [Symbol.split](string) {
    const array = string.split(" ");
    return array.reverse();
  }
}

console.log("Another one bites the dust".split(new ReverseSplit()));
// [ "dust", "the", "bites", "one", "Another" ]

명세서

Specification
ECMAScript Language Specification
# sec-symbol.split

브라우저 호환성

BCD tables only load in the browser

같이 보기