javascript like a pro

There are 5 tips that you want to know to be a pro.

  1. Ternary Operator

2. Nullish Operator

3. OR Operator

Find whether it isfalsy . If it is, then return the right expression.

4. Spread Syntax

By using Spread syntax, you are not only enhancing readability but also preventing side effects.

When you were to pass the original array to the parameter, it could possibly mutate your original array in the function.

5. Enum

By using Enum, you can handle human error. You or others can easily misspell the name of the colour.

Maybe you are not the person who is making spelling mistakes, but it is more readable when you use Enum.

--

--

Difference between Array and List in Javascript

Array

  • is a set of sequential items.
  • has an index for each item.

List

  • is a set of items(=node) ordered sequentially.
  • does not have an index for each item, but it has the reference for it’s next value

Can I access the item directly or sequentially?

Array

  • can access items either directly or sequentially.

List

  • can only be accessed sequentially. Because the list is stored in memory.

--

--