JavaScript Symbol.split Property

The JavaScript Symbol.split symbol serves the purpose of dividing a string at the positions that correspond to the regular expression.

Syntax

Example

Symbol.split(string)

Parameters

String

Return value

A string that split from the given expression

Browser Support

Chrome 32
Safari 8
Firefox 29
Opera 19

Example

Example

<script>

//JavaScript to illustrate Symbol.split

class Sp 

{

  constructor(value)

 {

    this.value = value;

  }

 [Symbol.split](string) 

{

var index = string.indexOf(this.value);

   return this.value; 

}

}

document.write("We split point from the string Example<br>")

document.write('Example'.split(new Sp('point')));

//expected output:We split point from the string Example

//point

</script>

Output:

Output

We split point from the string Example

point.

Input Required

This code uses input(). Please provide values below: