lol i love it. javascript looped itself around many times it can now be used
in anyway :D

On Fri, Aug 14, 2009 at 01:46, Pauan <pcxunlimi...@gmail.com> wrote:

>
> If you don't need private variables, you could make it even simpler:
>
> var person = {
>    first: '',
>    last: ''
> }
>
> var boy = Object.create(person);
> var girl = Object.create(person);
>
> In addition, now the variables "boy" and "girl" can also be
> prototyped:
>
> var otherBoy = Object.create(boy);
>
> Object.create works on objects, so functions are no longer necessary
> for prototypical inheritance in JavaScript. You'll still need
> functions if you want private variables, however. Lastly, we can use
> Object.create *right now* in all our code!
>
> http://javascript.crockford.com/prototypal.html
>
> It only supports the first parameter, though, not the second. So the
> above example would work, but Daniel Friesen's won't (until browsers
> get ES5 support).
>
> On Aug 13, 8:29 pm, Samer Ziadeh <samerzia...@gmail.com> wrote:
> > So how would this translate to the update method without the new keyword.
> >
> > function Person() {
> >   this.first = '';
> >   this.last = '';
> >
> > }
> >
> > var boy = new Person();
> > var girl = new Person();
> >
> > On Thu, Aug 13, 2009 at 21:48, Daniel Friesen <nadir.seen.f...@gmail.com
> >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > To create an object in ES3, yes. (ES3; ECMAScript 3; Current
> JavaScript)
> > > ES5 adds a new method which follow the proper prototypal method  (ES5;
> > > ECMAScript 5; The next version, ES4 was discarded)
> >
> > > Object.create(proto, {...});
> > > The first argument is a prototype to give it:
> > > Object.create(Foo.prototype); is roughly the same as,
> > > in mozilla js:
> > > ({ __proto__: Foo.prototpe })
> > > in normal js
> > > function F() {}
> > > F.prototype = Foo.prototype;
> > > new F;
> >
> > > Just so you know the {...} is a object listing keys to add. Each key
> has
> > > an object with data like value: (the value), or get: (a getter) and/or
> > > set: (a setter), as well as the attributes enumerable (part of for-in
> > > loops), writable (you can set it), and configurable (it can be removed
> > > using `delete o.prop`)
> >
> > > There's a nice new idiom which involves using Object.create inside a
> > > function, using that function's prototype as the proto, setting
> > > properties, and returning that object. Essentially it does the same as
> > > using `new Fn` except it gives you more control, and works whether you
> > > use new or not.
> >
> > > There's also an interesting new strawman that was recently brought into
> > > the harmony group, makes this possible:
> > > function Foo() {
> > >    return {
> > >       [parent: Foo.prototype],
> >
> > >       foo: "I'm a value",
> > >       const _bar: "You can't set or delete me after this",
> > >     };
> > > }
> >
> > > ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name
> ]
> >
> > > Samer Ziadeh wrote:
> > > > Isn't the 'new' a needed keyword?
> >
> > > > On Thu, Aug 13, 2009 at 08:04, Andrea Giammarchi
> > > > <andrea.giammar...@gmail.com <mailto:andrea.giammar...@gmail.com>>
> > > wrote:
> >
> > > >     Python rules, and I mainly agree, except the day "new" will not
> be
> > > >     necessary anymore we'll loose constructor duality, as functions,
> > > >     and implicit injected "init" methods.
> >
> > > >     Regards
> >
> > > >     On Tue, Aug 11, 2009 at 3:46 AM, Daniel Friesen
> > > >     <nadir.seen.f...@gmail.com <mailto:nadir.seen.f...@gmail.com>>
> > > wrote:
> >
> > > >         The requirement of "new" to create new js objects is an
> > > >         unnecessary
> > > >         piece of the language, in fact the need to use it disappears
> > > >         in ES5 as
> > > >         it's no longer the only way to create new objects with a set
> > > >         prototype.
> > > >         There's nothing strange about having a $ function and
> creating
> > > >         an object
> > > >         from it, in fact it's closer to real prototype-based
> > > >         programming than
> > > >         the `new Class` you see inside of JavaScript.
> >
> > > >         ~Daniel Friesen (Dantman, Nadir-Seen-Fire)
> > > >         [http://daniel.friesen.name]
> >
> > > > --
> > > > Samer Ziadeh
> > > >www.samerziadeh.com<http://www.samerziadeh.com>
> >
> > > > "Let It Be"
> >
> > --
> > Samer Ziadehwww.samerziadeh.com
> >
> > "Let It Be"
> >
>


-- 
Samer Ziadeh
www.samerziadeh.com


"Let It Be"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to