<textarea id="runcode64629"><P></textarea>
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
This method causes 100% Memory leakage in IE.
Try finally is easy to solve.CopyCodeThe Code is as follows: function createbutton (){
VaR OBJ = Document. createelement ("button ");
OBJ. innerhtml = "Click me! ";
OBJ. onclick = function (){
// Process the Click Event
}
OBJ. onmouseover = function (){
// Process the Mouseover event
}
Try {
Return OBJ;
} Finally {
OBJ = NULL; // This statement is executed after return, effectively solving the problem of setting OBJ to null after return.
}
}
In a function or method, in fact, there are many places where such an optional return value is required, and finally some things are executed
========================================================== ==================================
Appendix 1: javascript error (try/catch/finally)
Introduction
Like other programming versions, JavaScript provides the possibility to make use
The try/catch/Finally block. Usually when an error is encountered then the script stops and doesn' t
Continue with the rest of the page. The try/catch/Finally block can be used to continue
Processing with the rest of the page. You just have to put the code in your try block and when
An error in encountered there, then it will call the Catch Block. The Finally block is called always
Regardless of an error occurred or not. The following example makes the usage clear.
Example: