Deno claims to be browser-compatible. Does that mean it has a window / navigator object and what would that mean in terms of things like setting window.location?
The window object represents an open window in a browser. If a document contain frames (<iframe> tags), the browser creates one window object for the HTML document, and one additional window object for each frame.
The window object is not part of the DOM.
The window object is globalThe global object of JavaScript in the web browser is the window object. It means that all variables and functions declared globally with the var keyword become the properties and methods of the window object.
The global object in Deno is currently just called window
(and globalThis
due to upcoming ES standards, sadly). There is currently no navigator
/window.location
implemented.
The browser-compatible aspects of Deno are aiming to parts that are reasonable to exist even without under the browser environment, e.g. Event
, TextEncoder
, fetch
, etc. It would be an unnecessary burden to implement things like the complete DOM in the Deno core, and such tasks should be delegated to third-party modules (like JSDOM if ported to Deno)
Update: window.location
is added in Deno v0.3.0, pointing to the entry file's path (remote or local) (see usage in https://github.com/denoland/deno/issues/1750 , could be useful to implement something similar to Python's if __name__ == "__main__"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With