Solving memory leak in javascript with try-finally

In my previous post, I discussed how return statement is executed in try-finally clause. So in following program: string str = "original string"; try { return str; } finally { str = "changed in finally"; } the original value will be returned instead of the value changed in finally block. Would this feature be useful anywhere? Well, I can’t find anything in C#, but I can think up an example in javascript. First, let’s have a look of following javascrip code: function createDiv() { var div = document.createElement("div"); ......

Posted On Saturday, November 29, 2008 11:59 AM | Comments (8)

Copyright © Changhong Fu

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski