Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  A Javascript When Function

function when(conditionFunc, execFunc, interval){ if (conditionFunc()){ execFunc(); }else{ setTimeout(function(){ when(conditionFunc, execFunc, interval);}, interval); }}You have some code which should only execute when a condition is true. E.g. You have code which relies on a javascript library but can't be sure the library has loaded yet and don't want the code to execute until it has. This is common if you have a bookmarklet which injects more than one <script> tag or you have code which should only execute when an image or other asynchronously loaded element is...

3,689 0       JAVASCRIPT WHEN IMPLEMENTATION WHEN FUNCTION


  Valid JavaScript variable names

Did you know var π = Math.PI; is syntactically valid JavaScript? 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. Keywords are tokens that have special meaning in JavaScript: break, case, catch, continue, debugger,...

9,054 0       JAVASCRIPT STANDARD NAME CONVENTION


  Learn from Haskell - Functional, Reusable JavaScript

Learn You a Haskell: For Great Good?For the last couple months I have been learning Haskell. Because there are so many unfamiliar concepts, it feels like learning to program all over again. At i.TV, we write a lot of JavaScript (node.js and front end). While many functional/haskell paradigms don’t translate, there are a few techniques that JS can benefit from. There are Haskell library functions for everything. At first I thought this was just because it was mature, but then I noticed that these functions could be applied to a wider variety of problems than in other languages. This make...

2,213 0       JAVASCRIPT FEATURE HASKELL FUNCTIONAL REUSABILITY


  Avoiding and exploiting JavaScript's warts

One's sentiment toward JavaScript flips betweenelegance and disgust without transitingintermediate states.The key to seeing JavaScript as elegant is understandingits warts, and knowing how to avoid, work around or even exploit them.I adopted this avoid/fix/exploit approach after readingDoug Crockford'sJavaScript: The Good Parts:Doug has a slightly different and more elaborate take on the bad partsand awful parts,so I'm sharing my perspective on the four issues that have caused me the most griefin the past:how to fix broken block scope with with;the four (not three!) meanings of this;promoting ...

2,621 0       JAVASCRIPT VARIABLE THIS WARTS EXPLOIT WITH


  The Future of JavaScript � take a peek today!

The ECMA committee is working hard on designing the next version of JavaScript, also known as "Harmony". It is due by the end of next year and it is going to be the most comprehensive upgrade in the history of this language. Chrome and V8 are committed to pushing JavaScript forward and have already started implementing the new features. You can try some of them today in the latest dev channel release. Here’s a summary: Lexical scoping. Now "let" is the new "var" – traditional "var" declarations are complemented with "let" and "const". Both are properly block-scoped bindings, elimi...

3,720 0       JAVASCRIPT FUTURE FEATURE


  A re-introduction to JavaScript

IntroductionWhy a re-introduction? Because JavaScript has a reasonable claim to being the world's most misunderstood programming language. While often derided as a toy, beneath its deceptive simplicity lie some powerful language features. 2005 saw the launch of a number of high-profile JavaScript applications, showing that deeper knowledge of this technology is an important skill for any web developer.It's useful to start with an idea of the language's history. JavaScript was created in 1995 by Brendan Eich, an engineer at Netscape, and first released with Netscape 2 early in 1996. It was orig...

2,295 0       JAVASCRIPT OOP ARRAY TYPES RE-INTRODUCTION


  The future smells like JavaScript

Of course I am only repeating what others are preaching about the recent rise of JavaScript.But I think the movement is significant and can't be overstated. And recent developments are really even making it more and more interesting.Nobody can deny hat JavaScript is the de facto programming language of Html5. Every other language trying to bolt itself onto Html5 looks like pure friction so far. And Html5 is looking upon a prospering future.Today we are used to some established JavaScript frameworks that make working with JavaScript more fun and productive. jQuery seems to emerge as the clear l...

3,223 0       JAVASCRIPT FUTURE NODE.JS CLIENT-SIDE


  An Object is not a Hash

Following my article A String is not an Error, I want to bring attention to an issue that similarly applies to JavaScript in general, but has special relevance in the Node.JS environment.The problem boils down to the usage of {} as a data-structure where the keys are supplied by untrusted user input, and the mechanisms that are normally used to assert whether a key exists.Consider the example of a simple blog created with Express. We decide to store blog posts in memory in a {}, indexed by the blog post slug. For example, this blog post would be posts['an-object-is-not-a-hash'].We start writin...

42,356 3       JAVASCRIPT OBJECT HASH NODE.JS