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]

Tarini wrote:
> thanks guys for you answer but I know how to use $.each in OO context...
> I would like to understand why jQuery works in this way..
>
> What are the advantage using this inside closure instead of using a temp
> arguments like the index? I see only disadvantage...
>
> I also created a plugin (http://code.google.com/p/jquerycallback/) to
> manage callback using OO but this remain one of the (few) aspects of
> jQuery I don't like and I would like to get a reason :)
>
>
> Also...
> Thinking about OOP... are you really sure that jQuery isn't a OO library
> (or framework as you prefer)? 
> Two considerations about this relationship between jQuery and OOP:
> - jQuery selectors are a "strange" way to construct an object, an
> alternative constructor starting from a dollar sign and not with "new"
> keyword ( var divs = $("div") should be written as var divs = new
> jQuery("div") )
> - jQuery function (events, attributes, traversing, ecc...) are a lot of
> methods of jQuery object... they aren't simple namespaced function in a
> functional paradigm.
>
> (alternative) constructor + a lot of methods = object oriented
> programming
>
> why not?
>
>
> I hope to get some reply ;)
>
>
> On Fri, 2009-08-07 at 07:37 -0700, aHeckman wrote:
>   
>> @ludovic, javascript IS an object oriented language. There is no need
>> for simulation. It's just a different type of oop than classical.
>>
>> function Person (name) {
>>     this.name = name || 'Nobody';
>> }
>> Person.prototype = {
>>     sayName: function () {
>>         alert('Hi my name is ' + this.name);
>>     }
>> };
>> var ludovic = new Person('ludovic')
>>
>> On Aug 7, 8:13 am, ludovic <ludothebe...@gmail.com> wrote:
>>     
>>> If you want to keep you function's context, you can still do
>>>
>>> $('div').each( function() {
>>>      Context.myFunction( this );
>>>
>>> } );
>>>
>>> Anyway, I'm not sure it's a good idea to try to simulate object
>>> oriented syntax with javascript.
>>> It isn't an object oriented language and trying to make a language in
>>> a foreign paradigm is always heavy.
>>> But it is a personal opinion...
>>>
>>> ---
>>> Ludovic
>>>
>>>       
>
>
> >
>   

--~--~---------~--~----~------------~-------~--~----~
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