js url encode object code example
Example 1: js object to querystring
const params = {foo:"Hi", bar:"there"}
const queryString = new URLSearchParams(params).toString();
console.log(queryString);
Example 2: urlencode javascript
var url = encodeURIComponent('url');
Example 3: javascript object to params string
var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
Example 4: js urlencode
encodeURI("test uri");
encodeURI("test uri");
encodeURI("test uri/with a slash");
encodeURIComponent("test uri/with a slash");