Thursday, July 10th, 2008

Code specialization; Namespaces again; Parasitic inheritance

Category: JavaScript

Karl Krukow has a new blog that has some interesting Ajax content. Rather than pick at one, we have a synopsis of a few of his recent posts:

Manual code specialization

A technique is presented (in terms of examples) which can give performance boosts in certain situations. The technique relies on higher-order functions, and sharing variables in closures.

Namespacing again

Namespacing has been generally accepted (in one form or another) as a good thing. In this posting, a pair of functions: ‘namespace’ and ‘using’ are presented. The former ensures the existence of a namespace, similar to what is offered in common JavaScript libraries. However, it accepts more general forms of namespace declarations:


  1. namespace({
  2.  com: {
  3.    trifork: {
  4.     tribook: ['model','view','controller']
  5.     }}});

The latter function ‘using’ complements the namespace function. It brings a namespace into scope.


  1. using(com.trifork.tribook.model).run(function(m) {
  3.  m.Reservation = function(start,end){
  4.   //...
  5.  };
  6. });

Parasitic inheritance & instanceof

The object function advocated by Crockford in his work on parasitic inheritance makes a new object which has the input object as it’s prototype. However ‘instanceof’ doesn’t work with this function. A technique for combining these two is presented.

Posted by Dion Almaer at 10:37 am
Comment here

3.4 rating from 23 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.