background preloader

Javascript

Facebook Twitter

Keynote: AtScript - Google Slides. Stefano Azzolini : Fast Templating in JavaScript. You_don%27t_say. Chainvas: Chaining for everyone. Chain•vas |chānvəs| n. A tiny, modular library that can add chaining to any API that isn’t naturally chainable, like the Canvas API, the DOM and more. Only 1-2KB minified How does it work? Chainvas goes through all the methods in a prototype and wraps a function around them that returns the returned value or, if that is undefined, the function’s context (this).

Since the function context is our original object, we can keep calling methods without having to write the variable name over and over again, like this: obj.foo().bar().baz(); instead of this: obj.foo(); obj.bar(); obj.baz(); This practice is usually called chaining and was popularized by jQuery back in 2006. Obj .foo() .bar() .baz(); which not only saves you the extra bytes and typing, but is also much easier to read than both of the previous examples. chainvas also optionally adds a few helper methods (currently only one at the Core level, .prop()) to make chaining easier.

Chainvas’ Core does not modify any existing objects. DOM module. JavascriptTips - jslibs - JavaScript language advanced tips and tricks - standalone JavaScript development runtime environment with general purpose native libraries. These tips and tricks are not related to any web browser or any Document Object Model (DOM), they are only general purpose tips and tricks for the JavaScript language. Some of these tricks are using a latest version of JavaScript language (v1.8) and cannot run with the Microsoft Implementation of JavaScript (v1.5).

All these tricks has been tested with the Mozilla SpiderMonkey/TraceMonkey JavaScript engine (v1.8). You can try these examples using jshost, a command-line JavaScript interpreter. (download it). If you need more explanation about one of the following tips, don't hesitate to ask me or use the comment section at the end of this page. See the TOC at the end of the page. Append an array to another array var a = [4,5,6];var b = [7,8,9];Array.prototype.push.apply(a, b); uneval(a); // is: [4, 5, 6, 7, 8, 9] Milliseconds since epoch +new Date() // 1259359833574 Simulate threads using yield operator JavaScript 1.7 //// thread definitionfunction Thread( name ) { for ( var i = 0; i < 5; i++ ) { note. Buzz, a Javascript HTML5 Audio library. Javascript PC Emulator. Learning Advanced JavaScript.

ContentEditable jQuery.