JavaScript Symbol.split Property - JavaScript Tutorial

JavaScript Symbol.split Property

BLUF: This tutorial on JavaScript Symbol.split Property provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: JavaScript Symbol.split Property

Understanding JavaScript Symbol.split Property is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

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:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience