node js mysql result to string code example
Example 1: node js variable inside string
var my_name = 'John';
var s = `hello ${my_name}, how are you doing`;
console.log(s);
Example 2: javascript object to query string
function objectToQueryString(obj) {
var str = [];
for (var p in obj)
if (obj.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
}
var person = { first_name : "Marty",last_name : "Mcfly"};
var queryString=objectToQueryString(person);