Convert object into query string in javascript

Sometime we need to append query string to the current url for filtering or searching specific data. we can convert an object or array into query string using following code


var aQueryString = Object.keys(aParams).map(function(aKey)
{
   return aKey+ '=' + aParams[aKey]
}).join('&');

In above code aParams is your object