How to split a string into an array, in JS

October 26, 2018

You can use the split function on strings to return an array.

            let tags = "photo,photos,dogsofinstagram";
            let tagsArray = tags.split(","); // each word (tag) will be its own item in an array (it splits it wherever it found the comma.