I have 1 String Variable in JavaScript which contains 3 Comma separated values shown below:
var session = "[email protected],123456,f_id=8";
I want to get all above 3 comma separated values in 3 different variables. What I have achieved so far is getting last comma separated value in elem2 variable and getting other 2 comma separated values 1st and 2nd one in elem1 variable.
var elem1 = session.split(",");
var elem2 = elem1.pop();
document.write("elem1 = "+elem1+"<br/>elem2 = "+elem2);
So my program is not working fine as I wants, please I need quick working solution so that I have another variable elem3 and I will get following output in my browser:
elem1 = [email protected]
elem2 = 123456
elem3 = f_id=8
var [email, number, id] = session.split(",")