3 ms·
I don't quite agree with everything the author said. For example, the new keyword can make the code a lot more readable if you use it to call your own construct
by DrJokepu 16y ago
I don't quite agree with everything the author said. For example, the new keyword can make the code a lot more readable if you use it to call your own constructors (that is, functions that assume that "this" is referencing a newly created object).
Also, if you're dealing with DOM, you might want to avoid anonymous functions and closures as IE tends to not do proper garbage collection within closures and leak an awful lot of memory that doesn't get freed even after you visited another page. (This is an oversimplification, Google "IE DOM memory leaks" for a better description of the issue.) This is not JavaScript's fault, but still it is an important thing to consider as your users will hate you if your site is crashing their browser even if it's not your fault.
- btilly 16y agoAlso, if you're dealing with DOM, you might want to avoid anonymous functions and closures as IE tends to not do proper garbage collection within closures and leak an awful lot of memory that doesn't get freed even after you visited another page. To the best of my knowledge this was fixed in IE 7. Therefore I consider having such leaks on the general internet to be an underhanded service. Anything that leaves IE 6 usable but less pleasant encourages people to migrate to something better. ;-)
- DrJokepu 16y agoIt wasn't completely fixed in IE7, unfortunately: " However, as some web developers have pointed out, those changes don’t solve the problem entirely. IE still leaves behind anything not attached to the tree when we tear down the markup. In addition, sites that users keep open for extended periods of time, such as Web-based mail, can still cause IE’s memory usage to continually grow if the site doesn’t take care to avoid the leak patterns." http://blogs.msdn.com/b/ie/archive/2007/11/29/tools-for-detecting-memory-leaks.aspx http://blogs.msdn.com/b/ie/archive/2007/11/29/tools-for-dete... It's still a major pain in the back.