Fakin’ namespaces in Javascript

Look, namespaces can be faked!  Nuff said!  If something can be faked, do it!  That’s my motto!  Got me through college, for sure.  But – I digress.

Hmm, take aways?  Javascript doesn’t have namespaces – but wait!  What are namespaces?

Namespaces are wrappers to keep variables seperate and to stop variables with the same name from colliding.

So let’s say you got a variable with a generic name like ‘greet’ or something.  Then, somewhere else in your application, someone decides to make another variable called ‘greet’ that has a different value… Eww wee, that can become a problem – like quick.  SO, you can take your variables and attach them to another object other than the global object.  simple.  The video below will show you exactly how to do it!  Enjoy friends!



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s