Skip to content

Instantly share code, notes, and snippets.

@ufhy
Created February 20, 2020 13:17
Show Gist options
  • Save ufhy/52cfded48c289eb600b78b1cff31ddab to your computer and use it in GitHub Desktop.
Save ufhy/52cfded48c289eb600b78b1cff31ddab to your computer and use it in GitHub Desktop.
How to Turn an Object into Query String Parameters in JavaScript
// ES6
var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
const queryString = Object.keys(params).map(function(key) {
return key + '=' + params[key]
}).join('&');
// ES5
var queryString = Object.keys(params).map(function(key) {
return key + '=' + params[key]
}).join('&');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment