I am new to JavaScript.
I have an index.html file with following content:
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Section 2: JavaScript Language Basics</title>
</head>
<body>
<h1>Section 2: JavaScript Language Basics</h1>
</body>
<script src="script.js"></script>
</html>
...
Following are the contents of script.js:
var name = ['John', 'Mark', 'Jane'];
console.log(name[0]);
And the output I am getting in console window is 'J'. When I change the name of the variable to names or something other valid name, the output is correct: 'John'
Could you please help me in understanding what is causing this behavior?
Thanks