'Is there any alternative way to access JavaScript globals that have been shadowed or redefined?
For some unknown reason the name URL in my event handler points to a string value with the current URL of the browser instead of the constructor for an URL object. Trying to call it results in the following error:
Uncaught TypeError: URL is not a constructor
The string URL does not appear anywhere in the loaded document which leads me to believe that it is not redefined anywhere in my program. I have not been able to find anything other that would explain why this phenomena occurs.
So my question for a workaround is: Is it possible to access these global constructors in any other way?
Solution 1:[1]
Yes, through the name window, as long as it too hasn't been shadowed or redefined:
let a = new window.URL(location);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rovanion |
