JavaScript Split the string into an array of characters 1

JavaScript Split the string into an array of characters

// split the text into array of chars using empty string
console.log("ABCDEFGHIJK".split(''));

// split the text into array of chars using empty string and limit to 3 chars
console.log("ABCDEFGHIJK".split('', 3));

Here is what the above code is Doing:
1. The first console.log() statement is splitting the string into an array of chars using an empty string as the separator.
2. The second console.log() statement is splitting the string into an array of chars using an empty string as the separator and limiting the number of chars to 3.

Similar Posts