Split ,Reverse And Join String methods

ยท

1 min read

Split()

Split is a string method used to split a string into an array of substrings based on a specified delimiter.

which means the string will be split at each individual character. This effectively converts the string into an array of characters.

const str = "hello";
const arr = str.split('');
// arr is now ['h', 'e', 'l', 'l', 'o']

Reverse()

The reverse method is an array method that reverses the order of elements in an array.

const arr = ['h', 'e', 'l', 'l', 'o'];
const reversedArr = arr.reverse();
// reversedArr is now ['o', 'l', 'l', 'e', 'h']

Join()

The Join method is used to combine elements of an array into a single string, using a specified delimiter to separate the elements.

const reversedArr = ['o', 'l', 'l', 'e', 'h'];
const reversedStr = reversedArr.join('');
// reversedStr is now "olleh"

Technical word with meaning

delimiter - A delimiter is a character or sequence of characters used to separate or distinguish different parts of a text or data. It's commonly used in various contexts to define boundaries between elements, values, or tokens. Delimiters are crucial for parsing and processing data because they help identify where one piece of information ends and the next one begins.

ย