Some awesome js tricks you should know about
Ellie
Posted on February 15, 2021
When it comes to adding all the numbers in an array, most people would think of the 'for loop' to traverse all the numbers, but other than that, do you know you can also use array.forEach() and array.reduce()to do so? Let's take an example here!
There're also lots of array tricks you may not know about, take a look at the examples below:
(3) use array.reverse() to reverse a string:
(4) repeat certain string for multiple times
We all know that spread operator can be used to split an array into a pseudo array,but it can also used to copy an object in react project! Look at the example below:
(5)use spread operator to copy an object in class component.
...To be continued
Posted on February 15, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.