Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>There are two different ways to access an object property:</p>
<p>You can use .property or ["property"].</p>

<p id="demo"></p>

<script>
var person = {
    firstname:"John",
    lastname:"Doe",
    age:50,
    eyecolor:"blue"
};
document.getElementById("demo").innerHTML =
person["firstname"] + " is " + person["age"] + " years old.";
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy