Re:JQuery 2.0 Drops Support for IE6/7/8; API-Compatible with...
by MatthewPhillips on Thursday June 28, 2012 @10:05PM
(#4174912)
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.
Re:JQuery 2.0 Drops Support for IE6/7/8; API-Compatible with...
by ahoge on Saturday June 30, 2012 @09:20PM
(#4183426)
>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.
Re:JQuery 2.0 Drops Support for IE6/7/8; API-Compatible with...
by leaverou on Friday June 29, 2012 @11:22AM
(#4177051)
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.
Re:JQuery 2.0 Drops Support for IE6/7/8; API-Compatible with...
by ahoge on Saturday June 30, 2012 @09:23PM
(#4183438)
Yes, we can of course reinvent our own untested and undocumented triangular wheels.
But is that really the best possible use of your time?
Re:JQuery 2.0 Drops Support for IE6/7/8; API-Compatible with...
by salmanapk on Friday June 29, 2012 @12:16AM
(#4175213)
Good point.
BTW that could be written like this:-
[].forEach.call(document.querySelectorAll('p'), function (el) { console.log(el); });
Re:JQuery 2.0 Drops Support for IE6/7/8; API-Compatible with...
by apendleton on Friday June 29, 2012 @01:31AM
(#4175391)
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.
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.
vs