Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"SCRIPT5039: Redeclaration of const property" in IE9

This has been asked already, but the solution there did not help me. What does this mean exactly? My regular HTML page uses a "script" tag to load my main_script.js file, where the first thing I do is:

var internetExplorerSucks = 30;

The variable used be be called FPS, but I thought it might have been taken by some random default global, so I renamed it to something that obviously isn't already taken. Still it fails to work. I get this error in the IE debug console:

SCRIPT5039: Redeclaration of const property 
main_script.js, line 1 character 1

I tried making it a global by taking out "var", still didn't work. It should be noted that this is not in any function, just literally the first line of code in the file.

Some background: All of this code works perfectly in Chrome, Firefox, and Safari on Windows, OS X and Linux. IE is the only browser this does not work on. This project involves using an HTML5 canvas, which I got to at least display in IE 9 (I am using version 9), but this code does not immediately pertain to the canvas at all. In fact, I cannot seem to declare any variables whatsoever in my main_script.js file. I am able to, however, create functions without running into an error. Is that what I have to do? Put everything in a function (that would involve a lot of moving things around)?

Anyway, thanks for the help.

P.S. Internet Explorer is a nightmare.

like image 971
Sefu Avatar asked Nov 04 '22 01:11

Sefu


1 Answers

I had the same problem in my code and it turn out that IE show wrong line were the redeclaration appear. In my case it was history I use later in the code. You should check whole code for redeclaration of the constants. You can try to comment out part of the code and see when it throw that error.

like image 160
jcubic Avatar answered Nov 09 '22 17:11

jcubic