<html>
<body>
<h2>JavaScript Arrays</h2>
<p>Arrays use numbers to access its elements.</p>
<p id="demo1"></p>
<p id="demo2"></p>
<script>
var person = ["Shiv in Array", "Doe", 46]; //array
document.getElementById("demo1").innerHTML = person[0];
var man = {firstName:"Ashutosh", lastName:"Doe in Object", age:46}; //object
document.getElementById("demo2").innerHTML = man["firstName"] + " "+man.lastName; //TWO ways to access object properties
</script>
</body>
</html>
No comments:
Post a Comment