JavaScript language a- z cheat sheet Here is an A - Z list of some Javascript idioms and patterns. The idea is to convey in simple terms some features of the actual Javascript language (rather than how it can interact with DOM). Enjoy... Array Literals An array literal can be defined using a comma separated list in square brackets. Arrays in javascript have a wide selection methods including push() and pop(). In the example above, the chanceCivilisationCallback callback function is invoked by peakOil. Configuration Object Instead of passing around a bunch of related properties... Use a configuration object The use of a configuration object makes it makes it easier to write clean APIs that don't need to take a huge long list of parameters. Note: The closure is the object literal returned from annoymous function. Constructor Functions (Built in) There are no classes in Javascript but there are construtor functions which use the new keyword syntax similar to the class based object creation in Java or other languages. Then...
Semantic Versioning 2.0.0 | Semantic Versioning Javascript Territory - JSter Javascript Catalog JavaScript Standard Style Callback Hell Google JavaScript Style Guide 1 Introduction This document serves as the complete definition of Google’s coding standards for source code in the JavaScript programming language. A JavaScript source file is described as being in Google Style if and only if it adheres to the rules herein. Like other programming style guides, the issues covered span not only aesthetic issues of formatting, but other types of conventions or coding standards as well. 1.1 Terminology notes In this document, unless otherwise clarified: The term comment always refers to implementation comments. Other terminology notes will appear occasionally throughout the document. 1.2 Guide notes Example code in this document is non-normative. 2 Source file basics 2.1 File name File names must be all lowercase and may include underscores (_) or dashes (-), but no additional punctuation. 2.2 File encoding: UTF-8 Source files are encoded in UTF-8. 2.3 Special characters 2.3.1 Whitespace characters 2.3.2 Special escape sequences 2.3.3 Non-ASCII characters Example 7 JSDoc
You're Missing the Point of Promises This post originally appeared as a gist. Since then, the development of Promises/A+ has made its emphasis on the Promises/A spec seem somewhat outdated. Contrary to some mistaken statements on the internet, the problems with jQuery's promises explained here are not fixed in recent versions; as of 2.1 beta 1 they have all the same problems outlined here, and according to one jQuery core team member, they will forever remain broken, in the name of backward compatibility. Promises are a software abstraction that makes working with asynchronous operations much more pleasant. getTweetsFor("domenic", function (err, results) { // the rest of your code goes here to one where your functions return a value, called a promise, which represents the eventual results of that operation. var promiseForTweets = getTweetsFor("domenic"); I've talked about how cool I think promises are at length. Thenables and CommonJS Promises/A People mostly understand the first paragraph. What Is the Point of Promises?
Fantastic Micro-Frameworks and Micro-Libraries for Fun and Profit!