Colectarea gunoiului in javascript

Garbage Collection

In languages like C and C++, memory must be freed manually.

The JavaScript interpreter is able to detect when an object will never again be used by the program. When it determines that an object is unreachable (i.e., there is no longer any way to refer to it using the variables in the program), it knows that the object is no longer needed and its memory can be reclaimed.

Garbage collection is automatic and is invisible to the programmer. You can create all the garbage objects you want, and the system will clean up after you!
 
http://docstore.mik.ua/orelly/webprog/jscript/ch04_05.htm 


Variables scope chain


When JavaScript code needs to look up the value of a variable x (a process called variable name resolution), it starts by looking at the first object in the chain. If that object has a property named x, the value of that property is used. If the first object does not have a property named x, JavaScript continues the search with the next object in the chain. If the second object does not have a property named x, the search moves on to the next object, and so on.



http://docstore.mik.ua/orelly/webprog/jscript/ch04_07.htm

Niciun comentariu:

Trimiteți un comentariu