In this tutorial, you will find the easiest ways of splitting the string in small chunks breaking at a particular character.
For example, you have the following string:
jack brown~132 Street~Apt 20~New Jersey~NJ~12345
For splitting the strings, we should use the split() method like this:
According to ECMAScript6, the cleanest way is destructing arrays in the following way:
The split() method cuts the string into substrings, puts them into an array, and returns the array. The division is accomplished by searching for a pattern, where it is provided as the first parameter in the call of the method.