Day 14 of #100daysofCode

Bernar May
Sep 5, 2018 · 1 min read

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).

chibueze ukaegbu, phavor sparks, Shalom Mathew

LearnFactory Nigeria

At LearnFactory we Train proficient software, Outsource them for development work around the world and build software solutions for clients.

Bernar May

Written by

LearnFactory Nigeria

At LearnFactory we Train proficient software, Outsource them for development work around the world and build software solutions for clients.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade