JavaScript Common Pitfalls

This is a short list of common pitfalls in JavaScript, and some simple solutions for them. A lot of these problems arise from the deeply asynchronous nature of the language and may be applicable to other similar environments. Others are unique to JavaScript's attempts to be beginner friendly, and attempting to do something sensible given ambiguous input. Example code is also on GitHub here .