Simon Willison’s Weblog

Subscribe
Atom feed for jonathan-snook

1 item tagged “jonathan-snook”

2009

Why I don’t love JavaScript’s Module Pattern. Jonathan Snook points out that the module pattern (where private functionality is hidden in a closure and only public methods are revealed to outside scopes) makes code a lot harder to debug. I use the module pattern for pretty much everything, not because I want to keep stuff private but more to avoid any chance of leaking out in to the global namespace. If I need to debug a value I temporarily assign it as a property on the global window object.

# 30th April 2009, 7:59 pm / closures, debugging, javascript, jonathan-snook, modulepattern