Ravensroke
Ars Praetorian
Use Dojo, Require.js or another AMD loader to structure your javascript code; it'll make your life a lot easier.
Your second example is just a javascript "object" with methods; within the object you can use "this" to access your fields. Its mostly inferior to using modules, especially when you need to start creating more than one of something.
Your second example is just a javascript "object" with methods; within the object you can use "this" to access your fields. Its mostly inferior to using modules, especially when you need to start creating more than one of something.