Online Forum To Support Coders With Technical Assistance - Read Write Execute

Convert object into query string in javascript

Ankit Agrawal
Ankit Agrawal
Published on January 28, 2022 · 1 min read

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

Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article What are the falsy values in Javascript Next Article → What is the difference between –save and –save-dev in Node.js ?