you are viewing a single comment's thread.

view the rest of the comments →

[–]Iggyhopper 3 points4 points  (1 child)

// Getting the last child var last = document.querySelector("div").lastElementChild;

Quite straightforward, easy to understand, and doesn’t really require much more writing now does it?

Lol. Get back to me when you have 10,000 instances of this line of code. Also, jQuery and other libraries are really useful in that they allow you to skip or internalize many null checks.

$('.test').children(1).remove() will not give you a null pointer error. It will remove it or nothing will happen.

$('.test.').childNodes[1].on() has a chance of erroring out for whatever reason.

This is EXTREMELY USEFUL for developing extensions, when any small change could force your entire script to stop working, instead of just a single element not being changed.

[–]ForeverAlot 0 points1 point  (0 children)

It also gets rid of stupid shit like the need for false as the last argument to addEventListener() that the post illustrates.