Re: Inheritance?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Inheritance?

From: Douglas Crockford <nospam@sbcglobal.net>
Date: Mon Jan 23 2006 - 02:06:38 CET

> I don't necessarily think it's such a bad idea to have constructor
> methods. It looking like class based programming on the surface
> probably did a lot to get Javascript popular in the beginning. I'm
> just missing a direct approach to prototype based programming, e.g.,
> the clone method that other prototype based languages have.

I agree. I think JavaScript's attempt to dress a prototypal pattern up as a
classical pattern is confusing. So I made my own object function which produces
an object using another object as the prototype:

     function object(o) {
         function f() {}
         f.prototype = o;
         return new f();
     }

With the object function in my toolkit, I can program in a pure prototypal
style. I find it is very effective.

http://www.crockford.com/javascript/
Received on Tue Feb 7 21:18:37 2006