Marcel Mokos
Nov 30, 2018 · 2 min read

Part #6: Use the good parts avoid the bad parts

Javascript has good parts and React has the good parts too

The problem when the function takes more parameters

The problem with function arguments is that it gets complicated if the function can take more then one required and one optional parameter.

Reference of maximum parameters you should use

  • printCool function can have two parameters
  • the second parameter is optional

Reference of a function with more parameters then you should use

What if we want to call the function with the different end but keep the start

  • if you want to change the end parameter you have to reenter start argument
  • can you understand what is happening what are those values
  • imagine more arguments 🤯
printSolid("Javascript", "* >>> *", "* custom end *") 

Destructuring function parameters

How to do destructuring objects was covered in Part #5. As you already know function can have an object as an input.

Object argument is commonly used in React components and you will see this practice often.

Iterating over List or Collection of Objects

Most courses will torture you with for loops and while loops. We will have a different approach. We will use Array.map. The map is a method of Array object.

items.map((item) => { return item; }); // default does nothing
  • map always return a new Array

🚧 warning array will shill use reference for the nested arrays and other objects.

Testing javascript

You can use https://jestjs.io/ it is most popular and requires zero configuration.

Unit testing is better than debugging, me

Example of a simple function and simple test

ableneo Technology

Application Development, Data Science, Experience Platforms

Marcel Mokos

Written by

I'm fanatic to next generation Javascript lambda, yield, async/await everything. I admire typescript and flow types. Javascript will ultimately rule the world.

ableneo Technology

Application Development, Data Science, Experience Platforms

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