Day 14 of #100daysofCode
Today, I worked on destructuring and the for-in and for-of loop.
Destructuring:
One of the best ways to avoid conflict while passing arguments to a function is by destructuring. This allows you to pass in you arguments, as object and in any order(arrangement). How does it work?
Simply write the function parameters as an object and off course, give them default values. Therefor, while passing in your arguments, you equally pass them as objects with key value pairs. The key being the variables and the values, the value.
For-in and For-of loop:
This is an easy and simple way of looping through an array. Unlike the forEach, it can take in a break or continue within it. The major difference between them is
Difference Between For-in and For-of loop
For-in returns the index of the array elements, it iterates over key. While for-of returns the elements itself, it iterates over values.
For-in returns an altered array if altered, while for-of returns the exact array regardless (probably due to prototype).
