DEV Community

skptricks
skptricks

Posted on

Convert a string to an array of characters using ES6 spread syntax

Post Link : Convert a string to an array of characters using ES6 spread syntax

This tutorial explains how to Convert a string to an array of characters using ES6 spread syntax. Lets see the below examples, where we are using split method and spread operator to convert string to an array of characters.

Method -1 :
Lets see this example, where we are using split method to convert string to an array of characters.
var word = "skptricks Blog"

// using javascript split function.
var getData = word.split("");

console.log(getData)

Output:-

Array ["s", "k", "p", "t", "r", "i", "c", "k", "s", " ", "B", "l", "o", "g"]

Convert a string to an array of characters using ES6 spread syntax

continue reading...

Top comments (1)

Collapse
 
hsolatges profile image
hsolatges

Other ways and their benchmarks: jsben.ch/VuGAp
Note that spread operator is most often the slowest of all. Does it worth it in that case?