javascript

TwitterFacebook
Get flash to fully experience Pearltrees

Functional Parameters – a neat JavaScript Design Pattern - Joss Crowcroft

If your JavaScript application / library / plugin has default and settable parameters or options, for example a url or a color , and your code expects a string, what happens if the user (the developer) wants to pass in a function that returns a string, instead? The url / url() parameter in Backbone.js ‘Collections’ in Backbone.js have a url parameter, from where the data is fetched. It can either be a string, or a function that returns a string. In Backbone, when defining your collection, all of these are valid: http://www.josscrowcroft.com/2011/code/functional-parameters-a-neat-javascript-design-pattern/

Google JavaScript Style Guide

We follow the C++ formatting rules in spirit, with the following additional clarifications. Curly Braces Because of implicit semicolon insertion, always start your curly braces on the same line as whatever they're opening. For example: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml

toDataURL, Canvas, and SVG

http://ajaxian.com/archives/todataurl-canvas-and-svg Monday, October 5th, 2009 < p >I'm a fan of all the new ways of drawing on the web. I consider myself a Canvas evangelist, an SVG evangelist, and an evangelist for the new CSS Animation work going on. When asked "SVG or Canvas" I've long felt the right answer is: "Yes" :) Canvas is great at pixels, SVG is great at vectors, 'nuff said. Give me my scriptable image tag (Canvas) AND my easy scene graph (SVG).
http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth

Adequately Good - JavaScript Module Pattern: In-Depth - by Ben Cherry

The module pattern is a common JavaScript coding pattern. It's generally well understood, but there are a number of advanced uses that have not gotten a lot of attention. In this article, I'll review the basics and cover some truly remarkable advanced topics, including one which I think is original. The Basics We'll start out with a simple overview of the module pattern, which has been well-known since Eric Miraglia (of YUI) first blogged about it three years ago. If you're already familiar with the module pattern, feel free to skip ahead to "Advanced Patterns".

Asynchronous CommonJS Modules for the Browser (and Introducing Transporter) | SitePen Blog

Modules are an integral architectural piece of robust application development since they allow individual components to be developed with proper dependency management. Modules can specify dependencies and these can be automatically resolved and loaded to bring various pieces together automatically. In application development this is vastly more scalable and easier than having to track all the different dependencies and manually load modules or insert script tags. The CommonJS module format is increasingly ubiquitous as the de facto module format for JavaScript. However, if CommonJS modules, by themselves, are directly executed, they require synchronous loading of modules. Synchronous loading is known to be very problematic in the browser since it locks the browser user interface, requires eval-based compilation of scripts which confuses debuggers, and is less efficient than using standard script tags. http://www.sitepen.com/blog/2010/07/16/asynchronous-commonjs-modules-for-the-browser-and-introducing-transporter/
Usage § 1 Load JavaScript Files § 1.1 RequireJS takes a different approach to script loading than traditional <script> tags. Its goal is to encourage modular code. While it can also run fast and optimize well, the primary goal is to encourage modular code.

RequireJS

http://requirejs.org/docs/api.html#define