Skip to content

Instantly share code, notes, and snippets.

@jcoglan
Created October 10, 2012 13:24
Show Gist options
  • Save jcoglan/3865626 to your computer and use it in GitHub Desktop.
Save jcoglan/3865626 to your computer and use it in GitHub Desktop.
var qs = function(params) {
var pairs = [];
for (var key in params) {
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
}
return pairs.join('&');
};
console.log( qs({foo: 'bar', text: 'hi there', base64: 'Q/6+d=='}) );
// -> "foo=bar&text=hi%20there&base64=Q%2F6%2Bd%3D%3D"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment