Novel methods of Iterator and Set further refine the esthetics of JavaScript
Now it is even easier to handle NodeLists, Sets and Arrays and manipulate the DOM
JavaScript is a best choice for quick processing of data because no types need to be declared and also because you can chain Array
methods in short short statement instead of using multiple loops. Chaining allows for several sequential operations on a collection to be combined in one statement in a neat left-to-right manner, making the code easier to read and type.
By the way, the best feature of Java is undoubtedly the Streams API that is a more verbose but still more powerful analogue of JavaScript Array
methods. Unfortunately JavaScript Array
will never have once promised groupBy()
method.
In this post I review novel convenience methods that facilitate handling collections and make JavaScript code even cleaner.
New methods of Iterator
Iterator
, the object enabling iterable objects such as Set
or NodeList
has been enhanced with methods analogous the commonly used methods of Array
: map()
, flatMap()
, filter()
, take()
and drop()
(essentially analogues of slice()
), reduce()
, forEach()
, some()
, every()
, find()
and toArray()
. Those methods do not do anything new, they…