Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

memory leak in javascript

1: Accidental global variables
One of the objectives behind JavaScript was to develop a language that
looked like Java but was permissive enough to be used by beginners. One of the
ways in which JavaScript is permissive is in the way it handles undeclared
variables: a reference to an undeclared variable creates a new variable inside
the global object.

2: Forgotten timers or callbacks
The use of setInterval is quite common in JavaScript. Other libraries provide 
observers and other facilities that take callbacks. Most of these libraries 
take care of making any references to the callback unreachable after their own
instances become unreachable as well.

3: Out of DOM references
Sometimes it may be useful to store DOM nodes inside data structures. Suppose 
you want to rapidly update the contents of several rows in a table. It may make
sense to store a reference to each DOM row in a dictionary or array. When this
happens, two references to the same DOM element are kept: one in the DOM tree
and the other in the dictionary. If at some point in the future you decide to 
remove these rows, you need to make both references unreachable.

4: Closures
A key aspect of JavaScript development are closures: anonymous functions that 
capture variables from parent scopes. Meteor developers found a particular case
in which due to implementation details of the JavaScript runtime.
Comment

PREVIOUS NEXT
Code Example
Javascript :: datatables server side 
Javascript :: how to insert html into javascript 
Javascript :: array shuffle 
Javascript :: sqrt javascript 
Javascript :: first letter uppercase js 
Javascript :: how to hide ascending descending icons in datatable js 
Javascript :: jquery has parent with class 
Javascript :: Return the average of the given array rounded down to its nearest integer. 
Javascript :: javascript sort map by value 
Javascript :: how to repeat an array of objects n times in javascript 
Javascript :: Send Post Fetch REquest With Django 
Javascript :: export gcp credentials json file 
Javascript :: array javascript some vs every 
Javascript :: add dark mode to react 
Javascript :: timeout 
Javascript :: exporting a class 
Javascript :: javascript 2 return values 
Javascript :: jquery validation with ajax submit 
Javascript :: how to add json file to mongodb 
Javascript :: map array method create object 
Javascript :: sequelize findorcreate 
Javascript :: map list in javascript 
Javascript :: string number to array 
Javascript :: rotate camera three js 
Javascript :: js get words first letter 
Javascript :: debounce 
Javascript :: onload of modal jquery function 
Javascript :: react native custom debounce input 
Javascript :: react native scrollbar position issue 
Javascript :: remove element from array javascript by index 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =