my favorite

2011/04/30

YUI 3.3 Array method

in YUI 3.3 we have some syntax sugar to deal w/ dirty daily-life code snippets

In case I need a set of NodeList (myClass) elements, in previous version we have to use geeky style like below

Y.all(Y.all('.myClass')._nodes.slice(0, n-1));

not that elegant, right!?

Currently in YUI 3.3 we have public slice method for return NodeList, that say, we can use a better presentation

Y.all('.myClass').slice(0, n-1));

and it equals to below syntax in jQuery

$('.myClass:lt(n)')


Origin: https://github.com/rgrove/jquery-yui3-rosetta-stone/commit/849e4b115857e84ce5e54c1f1d3e2050cb12222a

No comments:

BIO

Taipei, GuTing, Taiwan

huang47 | personal

huang47 | personal