Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #8291
| From | beegee <bgulian@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: JavaScript: Object Definition Extension |
| Date | 2011-11-13 11:53 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <fa4cebe6-765e-4ea3-8eef-9a8ef2ade25b@y7g2000vbe.googlegroups.com> (permalink) |
| References | <887pb7titjugv9u6j6tiv9cjpdv8t6div7@4ax.com> <5d71fb87-8e00-4c50-96db-4ad31589600b@u5g2000vbd.googlegroups.com> <Ts$F80E5FYvOFwbw@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> <ceef2dee-d472-4831-a10f-1e2cd39a0988@i6g2000vbe.googlegroups.com> <xETYMiIXy6vOFwcd@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> |
On Nov 13, 6:40 am, John G Harris <j...@nospam.demon.co.uk> wrote:
> I think you've misunderstood Crockford's way. There is no extra
> intermediate object, but there are extra steps.
>
Crockford's way:
function object(o)
{
1) function F() {}
F.prototype = o;
2) return new F();
}
Your way (and mine sometimes):
1) Commercial.prototype=new RealEstate("Kamloops",150000);
There, I counted em for you. function F() {} is the intermediate
object and the reason you want to do this is exactly so that the new
object does *not* inherit pre-existing property values.
Now in this case, the OP wants to inherit existing property values and
perhaps create a number of child objects. I'm really ambivalent about
the value of classical OO in Javascript. I've used it effectively
exactly once and if I had to do it over, would probably go a different
route. Once you start down this road, you start missing the other
aspects of class inheritance like super constructors and destructors,
function overloading, interfaces and protected,private members. Each
of these paradigms has to be emulated in JS and to what purpose?
Far better, in my opinion, to focus on data/ui separation and
performance.
bob
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JavaScript: Object Definition Extension Gene Wirchenko <genew@ocis.net> - 2011-11-10 20:02 -0800
Re: JavaScript: Object Definition Extension "Evertjan." <exjxw.hannivoort@interxnl.net> - 2011-11-11 08:49 +0000
Re: JavaScript: Object Definition Extension beegee <bgulian@gmail.com> - 2011-11-11 05:40 -0800
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-11 20:11 +0000
Re: JavaScript: Object Definition Extension Gene Wirchenko <genew@ocis.net> - 2011-11-11 21:02 -0800
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-12 16:46 +0000
Re: JavaScript: Object Definition Extension Gene Wirchenko <genew@ocis.net> - 2011-11-14 12:26 -0800
Re: JavaScript: Object Definition Extension beegee <bgulian@gmail.com> - 2011-11-15 06:49 -0800
Re: JavaScript: Object Definition Extension beegee <bgulian@gmail.com> - 2011-11-15 09:47 -0800
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-15 15:43 +0000
Re: JavaScript: Object Definition Extension Gene Wirchenko <genew@ocis.net> - 2011-11-15 10:31 -0800
Re: JavaScript: Object Definition Extension Jake Jarvis <pig_in_shoes@yahoo.com> - 2011-11-15 23:35 +0100
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-16 20:42 +0000
Re: JavaScript: Object Definition Extension beegee <bgulian@gmail.com> - 2011-11-12 09:35 -0800
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-13 11:40 +0000
Re: JavaScript: Object Definition Extension beegee <bgulian@gmail.com> - 2011-11-13 11:53 -0800
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-14 16:19 +0000
Re: JavaScript: Object Definition Extension beegee <bgulian@gmail.com> - 2011-11-15 10:02 -0800
Re: JavaScript: Object Definition Extension Elegie <elegie@anonymous.invalid> - 2011-11-12 12:53 +0100
Re: JavaScript: Object Definition Extension Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-12 16:04 +0000
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-12 18:14 +0000
Re: JavaScript: Object Definition Extension Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-13 19:34 +0000
Re: JavaScript: Object Definition Extension Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-12 19:31 +0100
Re: JavaScript: Object Definition Extension Gene Wirchenko <genew@ocis.net> - 2011-11-13 20:33 -0800
Re: JavaScript: Object Definition Extension John G Harris <john@nospam.demon.co.uk> - 2011-11-12 16:52 +0000
Re: JavaScript: Object Definition Extension Elegie <elegie@anonymous.invalid> - 2011-11-12 20:49 +0100
Re: JavaScript: Object Definition Extension Gene Wirchenko <genew@ocis.net> - 2011-11-13 20:21 -0800
Re: JavaScript: Object Definition Extension Elegie <elegie@anonymous.invalid> - 2011-11-14 10:20 +0100
csiph-web