javascript closure(闭包)的一个示例
今天一个同事看到John Resig 的Pro JavaScript Techniques这本书上的37页上有一段关于闭包的javascript代码,怎么调试都运行不正确,于是和他一起研究了一下,代码是这样的: // Create a new user object that accepts an object of properties function User( properties ) { // Iterate through the properties of the object, and make sure // that it’s properly scoped (as discussed previously) for ( var i in properties ) { (function(){ //using this here is… Read More »