<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>JSON Get all Keys of objects in an Array</h1>
<p>Get a list of friends of 'Mike'.</p>
<button onclick="myFunction()">Click Me</button>
<script>
var data = [
{
"name": "Mike",
"age": 36,
"friends": [{
"jade": {
"gender": "female",
"age": 25
},
"antony": {
"gender": "male",
"age": 35
}
}]
}
]
function myFunction(){
console.log(Object.keys(data[0].friends[0]))
}
</script>
<p><strong>Note</strong>: Click on the button and check your console</p> </body>
</html>