Objects and other entities may be created and destroyed at will while a script is being executed.
Some are created automatically and some also get destroyed automatically. Some will be discarded when the script terminates either intentionally or accidentally due to an error of some kind.
Objects may only persist while a function is being executed. They may vanish when the function returns to its caller.
In a web browser, generally speaking, objects persist for the life of a page. They will be destroyed when the page is discarded or refreshed. Session storage can be accomplished effectively by maintaining a frame set where the outermost frame remains available throughout the session even though the pages it contains are replaced several times.
In a server-side environment, objects and entities will likely only persist during the request-response loop. Items may persist longer if the server-side implementation is able to archive them or if it is able to maintain session state information between one request and another.
In a TV set-top box environment, objects may persist for some time, perhaps for the duration of a broadcast program or for as long as the TV set-top box is tuned to a particular channel. Changing channels may purge out the object store. This particular kind of implementation is under constant and rapid development. One of the major areas of research is that of persistent and browsable cache systems where objects may repose and be recalled at will. In a system like that, objects may persist forever, or until the user chooses to dispose of them explicitly.