Accessing Elements
Accessing an Element
In order to access the elements of an array, we refer to their index number. The starting element of an array has an index value of 0.
var lang = [“C”,”C++”,”Java”];
So, var languages = lang[0]; // returns C
Code:
<html>
<body>
<h2>JavaScript Arrays</h2>
<script>
var lang = ["C","C++","Java"];
document.write(lang[1]);
</script>
</body>
</html>
Output: