I am new to javascript and today I tried one example, can someone help me explain why?
all tests run on the console from Chrome:
var greetingHello = "Hello";
var name = prompt("please enter your name");
document.write(greetingHello + " " + name + "<br>");
var name = new Array("name1","name2","name3");
document.write(name[0]);
Result n
But if I change the second variable "name" from "name" to "myName" and execute myName [0]
the result is "name1"
Why is this so strange?
source
share