I need to split a string into a specific size in JavaScript.
I know you can use Join
to turn a string
into a array
of letters:
'hello'.split('')
However, I need a way where I can determine the size at which this string will be broken.
For example, in PHP, we have the function str_split
where you can determine the size of these strings .
In the example below, I want to break the string by 3 in 3.
str_split ('stackoverflow', 3)
Result:
[
"sta",
"cko",
"ver",
"flo",
"w",
]
Is there any way to do this in JavaScript?