Archive for September, 2006

Javascript Daemon Manager Class

I found that I often have a little DHTML widget or something that might show up multiple times on the same page. If you approach that in an object-oriented way, that means that you’ve got a lot of little instances (daemons) running around handling each one, right? Then, I’d write a “manager” that [...]

Read the rest of Javascript Daemon Manager Class »

Function to spawn arbitrary object with arbitrary argument list in Javascript

Good news, everyone!
This function can be used to create an instance of an arbitrary class, and pass the list of arguments to the class’s constructor.
var spawn = function(cls, args) {
  if(!args instanceof Array) args = [args];
  var f=function(){};
  f.prototype=cls.prototype;
  f.prototype.constructor = cls;
  var obj = new f();
  cls.apply(obj,args);
  return obj;
};
Usage:
var myClass = function(a,b,c){ this.a=a; this.b=b; this.c=c; }
var myInstance = spawn(myClass,[1,2,3]); // same [...]

Read the rest of Function to spawn arbitrary object with arbitrary argument list in Javascript »

Real World Advice for Fledgling Web Developers

Today a fellow front-end engineer here at Yahoo! asked us for bits of real-world advice that we would give to up-and-coming front-end engineering students. He’s doing a talk at a school, and was curious about what we’ve learned. It struck me as a perfect idea for a blog post.
Any other front-end professionals out [...]

Read the rest of Real World Advice for Fledgling Web Developers »