String to object
const obj = JSON.parse('{"name":"John", "age":30, "city":"New York"}');
Copy object (not just put another pointer to it)
let newObj = JSON.parse(JSON.stringify(obj));
Sort object by key, capitalized letters will go first.
var data=Object.entries(query2).sort();
Copy an object, put all keys to lowercase
const newObj = Object.fromEntries( Object.entries(obj).map(([k, v]) => [k.toLowerCase(), v]) );
Iterate through an object
const object1 = { a: 'somestring', b: 42 }; for (const [key, value] of Object.entries(object1)) { console.log(`${key}: ${value}`); }
Object to array:
const arr = Object.entries(obj);