background preloader

JavaScript

Facebook Twitter

Knockout

Javascript loaders. Javascript Territory - JSter Javascript Catalog. Javascript on pluginGeek. The JavaScript Event Loop: Explained. What’s this post about?

The JavaScript Event Loop: Explained

With JavaScript approaching near-ubiquity as the scripting language of the web browser, it benefits you to have a basic understanding of its event-driven interaction model and how it differs from the request-response model typically found in languages like Ruby, Python, and Java. In this post, I’ll explain some core concepts of the JavaScript concurrency model, including its event loop and message queue in hopes of improving your understanding of a language you’re probably already writing but perhaps don’t fully understand. Who is this post for? This post is aimed at web developers who are working with (or planning to work with) JavaScript in either the client or the server. If you’re already well-versed in event loops then much of this article will be familiar to you. Non-blocking I/O In JavaScript, almost all I/O is non-blocking. Let’s compare two bits of code that make HTTP requests to www.google.com and output the response to console.

The Event Loop Web Workers. JavaScript. The core. Read this article in: Japanese, German (version 2), Arabic, Russian, French, Chinese.

JavaScript. The core.

This note is an overview and summary of the “ECMA-262-3 in detail” series. Every section contains references to the appropriate matching chapters so you can read them to get a deeper understanding. Intended audience: experienced programmers, professionals. We start out by considering the concept of an object, which is fundamental to ECMAScript. ECMAScript, being a highly-abstracted object-oriented language, deals with objects. An object is a collection of properties and has a single prototype object. Let’s take a basic example of an object. For the code: we have the structure with two explicit own properties and one implicit __proto__ property, which is the reference to the prototype of foo: Figure 1. What for these prototypes are needed? Prototype objects are also just simple objects and may have their own prototypes. Constructors Considered Mildly Confusing. JavaScript language a- z cheat sheet. Here is an A - Z list of some Javascript idioms and patterns.

JavaScript language a- z cheat sheet

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(). Suppose the world got taken over by a dictator who wanted to get rid of the last month of the year?

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. Rwaldron/idiomatic.js.

Callback Hell. You're Missing the Point of Promises. This post originally appeared as a gist.

You're Missing the Point of Promises

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. In the most basic definition, your code will move from continuation-passing style: 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.

Fantastic Micro-Frameworks and Micro-Libraries for Fun and Profit! Cujo.js. Hakimel/reveal.js. Sigma.js. Arbor.js. Js frameworks.