I want to convert an object like this:
let obj = {
arabicLang: false,
cancelVisitEmailAlert: false,
canselVisitSmsAlert: false
}
into an array of key-value pairs like this:
[
"arabicLang": false,
"cancelVisitEmailAlert": false,
"canselVisitSmsAlert": false
]
I read all questions in StackOverflow but none of them is my case
i try this but it return key and value in string:
let data = [];
for (const [key, value] of Object.entries(obj)) {
data.push(createData(key, value));
}
function createData(key, value) {
return key + ":" + value;
}
and also try this:
let arr = Array.of(obj)
console.log(arr)
/* output is
[{
arabicLang: false,
cancelVisitEmailAlert: false,
canselVisitSmsAlert: false
}]
*/
it keeps the object container