String to Array JavaScript

Tram Ho

Convert String to Array JavaScript? In this article, we will discuss how to convert from String to Array javascript. In this tutorial, we try to learn a lot of examples to give you a clear and holistic view. First, we want you to understand through a method that is very close to the devjs connection, the Split () method. But first, we want you not to be confused about split (), splice (), slice () .

The Split () method syntax

String to Array JavaScript Using JavaScript Examples

Here is a simple example:

No separator – str.split ();

Empty String Separator – str.split (”);

Separator – str.split (‘|’);

| may be another character that needs split

| may be another character that needs to be split, for example “,,”

The separator can be Regular Expression

Optional Limit Argument – limit array return

We can now limit the items returned in the array.

Ref: https://www.tutsmake.com/javascript-convert-string-to-array-javascript/

Share the news now

Source : Viblo