i just started a new html project as any other day, but totay i was suprised with scope colision in javascript. The point is i'm trying to declare a variable called top, but i think that i had already declared it in another file and i would like to know if there is a fast way to find this file and fix it.
This is my html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>day one</title>
</head>
<body>
<h1>hiii</h1>
<script src="script.js"></script>
</body>
</html>
This is my javascript:
let top = [0, 0, 0]
When i open the devtools and look at the console there is an error message there: script.js:1 Uncaught SyntaxError: Identifier 'top' has already been declared (at script.js:1:1)
So i tried to console.log()
the top variable and the output was the window
console.log(top)
// same thing as
console.log(window)
So i think that the best approach is trying to find original file where the top
variable is, any ideas?
I don't know what to do ;-; HELP PLEASEEEE
Via Active questions tagged javascript - Stack Overflow https://ift.tt/RbYJo8E
Comments
Post a Comment