I have a json file
{
"Val1":120,
"Val2":60,
"Val3":50
}
I need to pass those into two Global Arrays.
1st Array = ["Val1","Val2","Val3"]
2nd Array = [120,60,50]
You can use Object.keys & Object.values. Both of them will return array. Object.keys return array of keys and Object.values creates an array of values
let obj = {
"Val1": 120,
"Val2": 60,
"Val3": 50
}
let array1 = Object.keys(obj);
let array2 = Object.values(obj);
console.log(array1, array2)
Object.keys(o)and Array2 isObject.values(o)?