background preloader

Javascript

Facebook Twitter

Silk – Interactive Generative Art.

Js grids

Bookmarklet Crunchinator. JavaScript Garden. Although JavaScript deals fine with the syntax of two matching curly braces for blocks, it does not support block scope; hence, all that is left in the language is function scope. function test() { // a scope for(var i = 0; i < 10; i++) { // not a scope // count } console.log(i); // 10} There are also no distinct namespaces in JavaScript, which means that everything gets defined in one globally shared namespace. Each time a variable is referenced, JavaScript will traverse upwards through all the scopes until it finds it. In the case that it reaches the global scope and still has not found the requested name, it will raise a ReferenceError. The Bane of Global Variables // script Afoo = '42'; // script Bvar foo = '42' The above two scripts do not have the same effect.

Again, that is not at all the same effect: not using var can have major implications. // global scopevar foo = 42;function test() { // local scope foo = 21;}test();foo; // 21 Local Variables var foo = 3; bar = 4;}test(10); Hoisting. Head.JS, the only script in your HEAD. Mozilla/doctorjs. Crossroads.js: JavaScript Routes System. Crossroads.js can be used as a regular JS file creating a global crossroads variable, an AMD module which doesn’t generate any global variables and also as a CommonJS module. You can use the same distribution file for all the environments (since v0.6.0). crossroads.addRoute(pattern, [handler], [priority]):Route Creates a new route pattern listener and add it to crossroads routes collection. Parameters pattern:String|RegExp String pattern or Regular Expression that should be used to match against requests.

If pattern is a String it can contain named variables surrounded by "{}" that will be evaluated and passed to handlers as parameters. The pattern "{foo}/{bar}" will match "lorem/ipsum-dolor" but won't match "lorem/ipsum-dolor/sit". A pattern can also have optional segments, which should be surrounded by "::" (e.g. If pattern is a RegExp, capturing groups will be passed as parameters to handlers on the same order as they were matched.

[handler]:Function (optional) [priority]:Number (optional) Kaffeine. Kaffeine is a set of extensions to the Javascript syntax that attempt to make it nicer to use. It compiles directly into javascript that is very similar, readable and line for line equivalent to the input (you can beautify if you like). Philosophy opt-in extensions: vanilla Javascript works as normallimited but focussed feature setHackable, modular, extendable and testableLine-for-line equivalence for easy debugging (unless beautified) Overview zoo = {} square = { # * # } open door users | select { #.age > 18 } for user of users send.welcome user if Job.count!

Var _a, user, zoo, square; zoo = {} square = function() { return arguments[0] * arguments[0] } open(door) __.select.call(this, users, function() { return arguments[0].age > 18 }) for(_a = 0; _a < users.length; _a++) { user = users[_a]; send.welcome(user) } Job.count(function(_0) { if(_0 > 10) { retrieve(function(_1) { var data; data = _1 process(data) })} }) Features Optional colons Optional semi-colons. Danbentley/placeholder. Ligature-js - JavaScript to convert text patterns into common typographic ligatures. jQuery Plugin Boilerplate, revisited. Get the latest updates on this jQuery plugin via RSS A boilerplate for jump-starting jQuery plugins development. Contains lots of comments to help you get going easily. It implements public and private methods, as well as public and private properties making it the ideal candidate for when building both simple and complex jQuery plugins.

It does not adhere to the suggestions made by the jQuery documentation regarding Plugins/Authoring. The jQuery Plugin Boilerplate took some inspiration from Doug Neiner‘s Starter. With comments: Without comments: Usage Requirements jQuery 1.5.2+ It’s the only version I’ve tested the boilerplate with; it may be applicable to earlier versions, too. 54 responses to “jQuery Plugin Boilerplate, revisited” jQuery Waypoints. FitText - A plugin for inflating web type. Yepnope.js | A Conditional Loader For Your Polyfills! Modernizr: the feature detection library for HTML5/CSS3. Modernizr: the feature detection library for HTML5/CSS3.