1

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?

2
  • 2
    if 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. Commented Dec 12, 2013 at 18:49
  • @MarcB but, can the page javascript observe the document be no longer reachable? Say, from another window? Commented Dec 12, 2013 at 18:49

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Excelent, your dispel my doubts!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.