Monthly Archives: August 2009

“Even Faster Websites”

OReily Even Faster Websites is a great book. It has some Javascript perfomance hints in its “Writing Efficient JavaScript” part. Here are conclusions: Use local variables Avoid with statement do not use too deep properies, redefine them with locals if possible Use the if statement when: — There are no more than two discrete values for which to test. — [...]
Posted in post | Leave a comment

take control over class constructor

Javascript doesn’t give us simple way to control object constructing. We have new operator, but we cannot control it. Unless we do some magic. Lets assume we have an observer instance, few classes and we want every instance of this classes to be ‘observed’. var observer=[]// simplest ever function foo(){ this.foo="foo"; [...]
Posted in post | Tagged | Leave a comment

javascript constructor with arguments

There was an interesting question on stackoverflow recently. Nobody had right answer. Now after few days i got it! It is really a peace of JS art. The question was if it is possible to call constructor like this: someClass(arg1,arg2,...,argN){ .... //implementation } having just an Array of arguments [arg1,arg2,...,argN]. First thought was just to use apply. Next was: how [...]
Posted in post | Tagged , | Leave a comment