background preloader

Javascript / Patterns

Facebook Twitter

Functional Programming in Javascript. This is an interactive learning course with exercises you fill out right in the browser.

Functional Programming in Javascript

If you just want to browse the content click the button below: This is a series of interactive exercises for learning Microsoft's Reactive Extensions (Rx) Library for Javascript. So why is the title "Functional Programming in Javascript"? Well it turns out that the key to learning Rx is training yourself to use functional programming to manipulate collections. Functional programming provides developers with the tools to abstract common collection operations into reusable, composable building blocks. Map filter concatAll reduce zip Here's my promise to you: if you learn these 5 functions your code will become shorter, more self-descriptive, and more durable.

Finishing the Interactive Exercises This isn't just a tutorial, it's a series of interactive exercises that you can fill out right in your browser! Note: Use the "F4" key to toggle full screen mode for each editor. Working with Arrays Querying Trees. JavaScript Patterns. JSComplexity.org. Eloquent JavaScript: A Modern Introduction to Programming. Closure Compiler Service. Closure-compiler - Closure Compiler. Closure Compiler Closure Compiler is a JavaScript optimizing compiler.

closure-compiler - Closure Compiler

It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls. It is used in many of Google's JavaScript apps, including Gmail, Google Web Search, Google Maps, and Google Docs. Try it out! It's easy to try the compiler through our web application at Get the Compiler Download the compiler at or using Maven.

The zip file contains a README with quick instructions to get you started. User Documentation You can read more about Closure Compiler at We also have a few low-key wiki pages at Please suggest new ones if you see anything missing. Developer Documentation The Closure Compiler javadocs are available at You can browse the source at We accept patches :) ECMAScript 5 Strict Mode, JSON, and More. Previously I analyzed ECMAScript 5’s Object and Property system.

ECMAScript 5 Strict Mode, JSON, and More

This is a huge new aspect of the language and deserved its special consideration. There are a number of other new features and APIs that need attention, as well. The largest of which are Strict Mode and native JSON support. Strict Mode. Jslibraryboilerplate by dciccale. An easy boilerplate for rolling your own JavaScript Library like jQuery, Zepto, Prototype, etc.

jslibraryboilerplate by dciccale

The code is written in CoffeeScript, TypeScript and pure JavaScript. Skip this if you want to use pure JavaScript version For compiling CoffeeScript or TypeScript you will need to install Node.js After installing Node.js you can compile the files throgh command-line Install CoffeeScript package: npm install -g coffee-script Compile file: Prototypal Inheritance. Douglas Crockford www.crockford.com Five years ago I wrote Classical Inheritance in JavaScript (Chinese Italian Japanese).

Prototypal Inheritance

It showed that JavaScript is a class-free, prototypal language, and that it has sufficient expressive power to simulate a classical system. My programming style has evolved since then, as any good programmer's should. I have learned to fully embrace prototypalism, and have liberated myself from the confines of the classical model. My journey was circuitous because JavaScript itself is conflicted about its prototypal nature. New () Prototype-based programming. A fruit bowl serves as one example.

Prototype-based programming

A "fruit" object would represent the properties and functionality of fruit in general. A "banana" object would be cloned from the "fruit" object, and would also be extended to include general properties specific to bananas. Each individual "banana" object would be cloned from the generic "banana" object. Design and implementation[edit] Prototypal inheritance in JavaScript is described by Douglas Crockford as: you make prototype objects, and then ... make new instances.

Almost all prototype-based systems are based on interpreted and dynamically typed languages. Object construction[edit] Systems that support ex nihilo object creation allow new objects to be created from scratch without cloning from an existing prototype. This example in JS 1.8.5 + ( see ) Delegation[edit] Concatenation[edit] The main conceptual difference under this arrangement is that changes made to a prototype object are not automatically propagated to clones. Criticism[edit] Top Down Operator Precedence. Douglas Crockford Introduction Vaughan Pratt presented "Top Down Operator Precedence" at the first annual Principles of Programming Languages Symposium in Boston in 1973.

Top Down Operator Precedence

In the paper Pratt described a parsing technique that combines the best properties of Recursive Descent and Floyd's Operator Precedence. Valid JavaScript variable names. Did you know var π = Math.PI; is syntactically valid JavaScript?

Valid JavaScript variable names

I thought this was pretty cool, so I decided to look into which Unicode glyphs are allowed in JavaScript variable names, or identifiers as the ECMAScript specification calls them. Reserved words The ECMAScript 5.1 spec says: An Identifier is an IdentifierName that is not a ReservedWord. The spec describes four groups of reserved words: keywords, future reserved words, null literals and boolean literals. JavaScript variable name validator. Wondering if you can use a given string as a variable name in JavaScript?

JavaScript variable name validator

Learn how it works, or just use this tool. <strong>To use this tool, please <a href= JavaScript</a> and reload the page. </strong> Rwldrn/idiomatic.js.