Hacker Newsnew | comments | show | ask | jobs | submit login

>[IE8] was released in 2009!

Yep, it's ancient. Chrome and Firefox are on average about 3 weeks old. IE8 is over 50 times older.

>jQuery's main raison d'être might have gone out the window.

Normalization was just one part. It still provides a much nicer API. There are also events, AJAX, effects, and some useful helpers.

    [].slice.call(document.querySelectorAll('p')).forEach(function (el) {console.log(el);});
vs

     $('p').each(function () {console.log(this);});



Agreed, [].slice.call is show-offy and pointless. Array.prototype.slice.call is the way to go.

I hope you realize that by saving yourself a few characters you've sacrificed an unknown amount of performance from your site. For such a simple query I'd use getElementsByTagName instead.

-----


>Array.prototype.slice.call is the way to go.

The point was to demonstrate that the API is somewhat flawed since it doesn't return something usable. The "clever" short version was used to show that you have to write quite a bit more code - even if you make it really ugly.

>For such a simple query I'd use getElementsByTagName instead.

It's a generic example. The selector was kept short and simple for the sake of brevity.

-----


Um, when did we forget how to write our own abstractions? It’s not black and white, either jQuery or vanilla JS with no helpers.

-----


Yes, we can of course reinvent our own untested and undocumented triangular wheels.

But is that really the best possible use of your time?

-----


Good point.

BTW that could be written like this:-

  [].forEach.call(document.querySelectorAll('p'), function (el) { console.log(el); });

-----


Array.prototype.forEach didn't arrive in IE until 9, so if the point is that you can do anything that jquery can do, this won't work.

-----


huh? Might want to check the comment I was replying to.

-----




Applications are open for YC Winter 2016

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: