I have one json object as below :
{
"firstObject": [
{
"element": ".branding",
"details": "Hello"
},
{
"element": "button.login",
"details": "Hi "
},
{
"element": "#step3",
"details": "How are you "
}
],
"secondObject": [
{
"element": ".branding",
"details": "Hello"
},
{
"element": ".step12",
"details": "Hi "
},
{
"element": "#step2",
"details": "How are you "
}
]
}
And I have below function where above object is passed as parameter (steps):
function getStateSteps (state, steps) {
console.log('TESTTT 1', steps);
let x = Object.keys(steps);
console.log('TESTTT 2', x);
}
Here, In TESTTT 2 log, 'x' is returning index values of strings instead of key of JSON object.But when I am checking for same object in browser console I am getting the correct output. I have attached the screenshot of my browser console. Can someone please point out what is going wrong?
console screenshot


JSON.parse(steps)or you didn't parse before passing the value to the function. So you are just passing around the JSON text string not an object