How to Split a String into an Array in JavaScript
Learn how to split a string into an array.
Posted in these interests:
The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.
var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false
How to Split a String into an Array in JavaScript
Learn how to split a string into an array.
Posted in these interests:
The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.
var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false
How to Split a String into an Array in JavaScript
Learn how to split a string into an array.
Posted in these interests:
The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.
var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false
How to Split a String into an Array in JavaScript
Learn how to split a string into an array.
Posted in these interests:
How to Split a String into an Array in JavaScript
javascriptcodePosted in these interests:
The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.
var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false
The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.
var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false
The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.
var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false
String.split
Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.