Using a method would be jQuery like:
-> http://api.jquery.com/first/
-> http://api.jquery.com/last/
but jQuery didn't had much choice has JS getter / setter are not supported by 
older browsers

The DOM API expose first / last child via properties since DOM level 1
-> http://www.w3.org/TR/dom/#dom-node-firstchild
-> http://www.w3.org/TR/dom/#dom-node-lastchild

As does Element Traversal
-> 
http://www.w3.org/TR/2007/WD-ElementTraversal-20070727/#elementTraversal-firstElementChild
-> 
http://www.w3.org/TR/2007/WD-ElementTraversal-20070727/#elementTraversal-lastElementChild

Properties would be more logic to me but I'm not sure if they are really 
necessary
It provides a little more semantic friendly access and is a little more 
friendly for autocompletion

On 28 juil. 2013, at 14:13, David Bruant wrote:

> Hi,
>
> Asked by Angus Croll [1]. Interestingly, people who answered giving code
> didn't agree on a method or getter. Hence the need for a standard :-)
> Array.prototype.first could work too.
>
> David
>
> [1] https://twitter.com/angustweets/status/359827047117373443
>



Alexandre Morgaut
Wakanda Community Manager

4D SAS
60, rue d'Alsace
92110 Clichy
France

Standard : +33 1 40 87 92 00
Email :    alexandre.morg...@4d.com
Web :      www.4D.com


_______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to