Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h2>Access Nested JavaScript Objects</h2>
<p id="demo"></p>
<script>
const myObj = {
  "name":"John",
  "age":30,
  "cars": {
  "car1":"Ford",
  "car2":"BMW",
  "car3":"Fiat"
  }
}
document.getElementById("demo").innerHTML = myObj.cars.car2;
</script>
</body>
</html>