Javascript module pattern introduced in TGP deentityify method - why is this pattern necessary?
问题 Crockford introduces a pattern in the deentityify method to create a module. He claims: The module pattern takes advantage of function scope and close to create relationships that are binding and private. In this example, only the deentityify method has access to the entity data structure. Distilling to remove his custom functions, I think the code boils down to... String.prototype.deentityify = function() { var entity = { quot: '"', lt: '<', gt: '>' }; return function() { return this.replace