Thursday, July 10th, 2008
Code specialization; Namespaces again; Parasitic inheritance
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:
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 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:
-
-
namespace({
-
com: {
-
trifork: {
-
tribook: ['model','view','controller']
-
}}});
-
The latter function 'using' complements the namespace function. It brings a namespace into scope.
-
-
using(com.trifork.tribook.model).run(function(m) {
-
-
m.Reservation = function(start,end){
-
//...
-
};
-
});
-
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.












Leave a comment