Convert object into query string in javascript

{ // deep_execution_view
const authorName = "Ankit Agrawal";
//
const publishDate = "January 28, 2022";

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

}