News for hackers. Stuff that matters.
Re:How true hackers write JavaScript by qbonnard on Wednesday September 05, 2018 @03:49AM (#17915890)
> function addClass (el, cl) { if (el) { var a = el.className.split(' '); if (!afind(cl, a)) { a.unshift(cl); el.className = a.join(' ')}} }

Why does it use `unshift` rather than `push` ?

The only reason I can think of is that the last class added will be faster to remove when iterating over the array...

There are no comments on this comment yet.