1
I saw that ES6 tends to be cleaner, but I can’t understand some things:
1. What exactly is this reticence doing, in theory?
function getHiddenHTML(el) {
return [...el.childNodes].reduce((txt, node) => {
//results
});
I know it would be something like this at ES5, to work, which left me even more confused, what exactly these functions are doing, I would like a theoretical explanation about it, thanks:
function _toArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function getHiddenHTML(el) {
return _toArray(el.childNodes).reduce(function(txt, node){
//results
});