Array slice creates a shallow copy of an array. In this lesson we cover, in detail, exactly what a 'shallow' copy is and how it can trip people up. We go on to look at examples that show to how to copy only the first item, the last item and even how to copy a sub-section of an array excluding the first and last. We end the lesson with a practical example that shows how slice
fits into a workflow that contains other array methods such as map
& reduce
.
Awesome example at the end.
Why on earth do you mix map and reduce here, i have no clue what they do, similarly in earlier example , you have used file objects like path, this is terrible .. i am not understanding any thing here ... sorry but when i pay , i expect better
I don't understand the syntax. :? For prev next, how does prev figure out it's 'Shane Osbourne' and then moves over the elements? I need more info here
What does => do? I've not seen it before.
I don't understand the syntax. :? For prev next, how does prev figure out it's 'Shane Osbourne' and then moves over the elements? I need more info here.
That is how reduce work, we pass the ref variable that contains the value 'Shane Osbourne' , ref is the initial value passed to reduce ex: items.reduce(callbackFn, initialValue);
Hope you get it now, Regards. jzamit
What does => do? I've not seen it before.
It is an arrow function used with an implicit return, ex: const name = 'jzamit'; console.log(name => name.toUpperCase()); // JZAMIT
Hope you get it now, Regards. jzamit
the ending was so confusing
pretty cool. like this.