Reputation: 1295
I need to be able to break down a string into separate variables based on a :
Here are two possibilities of two separate strings
localAction:connectPage
localAction:product:<Id>
I want to break this down into
first variable = name
second variable (if set) = id.
Upvotes: 0
Views: 102
Reputation: 187034
To expand on esqew
's comment...
var string = "localAction:connectPage";
var pair = string.split(":"); // the magic
var name = pair[0];
var id = pair[1];
console.log(name); // "localAction"
console.log(id); // "connectPage"
Upvotes: 1