We just gather all the stuff from top developers and put here. Since it come from exceptional folks, we could say that it is "the right way", or the best way to do so.
Nowadays the best tool to linting your JS code is the JSHint. We recommend that whenever possible you verify your code style and patterns with a Lint tool.
Anonymous functions are functions that are dynamically declared at runtime. They’re called anonymous functions because they aren’t given a name in the same way as normal functions.
Hoisting: On runtime, all var and function declarations are moved to the beginning of each function (its scope) - this is known as Hoisting. Having said so, it is a good practice to declare all the vars altogheter on the first line, in order to avoid false expectations with a var that got declared late but happened to hold a value before - this is a common problem for programmers coming from languages with block scope.
Closures are functions that refer to independent (free) variables. In other words, the function defined in the closure 'remembers' the environment in which it was created in. It is a important concept to understand, it can be usefull to development like emulating private methods. And it can help to learn how avoid a common mistake like creating closures in loops.
Source: MDN - Closures
Source: MDN - Strict mode
This pattern has been referred to as a self-executing anonymous function, but @cowboy (Ben Alman) introduced the term IIFE as a more semantically accurate term for the pattern.
Creational Design Patterns
Structural Design Patterns
Behavioral Design Patterns
Maintained by TJ Holowaychuk
Maintained by jQuery
Maintained by Pivotal Labs
Maintained by the team behind AngularJS. Mostly by Vojta Jina
Maintained by Sitepen
A test helper to mock functions and the XHR object, maintained by Leo Balter
Very popular JS client-side framework, built by @jashkenas.
Built by @wycats, jQuery and Ruby on Rails core developer.
Built by Google, Angular.js is like a polyfill for the future of HTML
Cappuccino is an open source framework that makes it easy to build desktop-caliber applications that run in a web browser.
MelonJS is a free, light-weight HTML5 game engine. The engine integrates the tiled map format making level design easier.
ImpactJS is one of the more tested-and-true HTML5 game engines with the initial release all the way back at the end of 2010. It is very well maintained and updated, and has a good-sized community backing it. There exists plenty of documentation - even two books on the subject of creating games with the engine.
LimeJS is a HTML5 game framework for building fast, native-experience games for all modern touchscreens and desktop browsers.
Cocos2d-html5 is an open-source web 2D game framework, released under MIT License. It is a HTML5 version of Cocos2d-x project. The focus for Cocos2d-html5 development is around making Cocos2d cross platforms between browsers and native application.
Turbulenz is backed by $5M in venture funding. The engine is very polished, and primarily focused on high-quality HTML5 games. There appears to be less support for mobile devices, but they will soon catch up when all mobile devices support webGL.
Kiwi.js is a fun and friendly Open Source HTML5 Game Engine. Some people call it the WordPress of HTML5 game engines
Panda.js is a HTML5 game engine for mobile and desktop with Canvas and WebGL rendering.
by Yehuda Katz
by Scott Allen
by Yehuda Katz
by Ben Alman
by Ryan Burgess
by James Coglan
by Dustin Diaz
by John Resig
by Ryan Burgess