In JavaScript, split
behaves a litte different than expected. For example, we have a string needed to be split into pieces:
|
|
Say, we need to split and format the above string into:
|
|
If we use split
without limitation:
|
|
Actually, we got:
|
|
So we add another argument:
|
|
Got Only [Steve Jobs]
. The result is not we except. The second argument just identify how many elments in the spilt pieces would return.
So we need to do the split
ourself:
|
|