let url = new URL("https://stackoverflow.com/questions/ask")
It will get an error like this:
URL is not defined
Actually, in modern browsers, it works well. However, if you run it in the node.js
environment, you will get an error like that.
I researched the documentation, it says it's a global class:
Browser-compatible URL class, implemented by following the WHATWG URL Standard. Examples of parsed URLs may be found in the Standard itself. The URL class is also available on the global object.
So, what's the problem?