I'm newbie in JavaScript and want to ask a base question. When document is creating and what's the lifecycle of this object? As i understood, document is a client-side object. Is it true? When document is destroy by garbage collector?
-
2if you're dealing with a browser environment, then document will NEVER be destroyed until the browser leaves the current page, because document IS the current page.Marc B– Marc B2013-12-12 18:49:01 +00:00Commented Dec 12, 2013 at 18:49
-
@MarcB but, can the page javascript observe the document be no longer reachable? Say, from another window?John Dvorak– John Dvorak2013-12-12 18:49:48 +00:00Commented Dec 12, 2013 at 18:49
Add a comment
|
1 Answer
If you're working in a browser-based environment, document is everlasting. Immortal. document simply refers to the current page you're on. Go to your Javascript console in your browser. Try assigning something to document, then see what the value of document is. It won't have changed. If you're not running it on the browser, then document has no special meaning, and you can do whatever you want with it.
1 Comment
St.Antario
Excelent, your dispel my doubts!