DEV Community

Cover image for 10 JavaScript tips that can help you understand this programming language better
Pasca Vlad
Pasca Vlad

Posted on

10 JavaScript tips that can help you understand this programming language better

If you found value in this thread you will most likely enjoy my tweets too so make sure you follow me on Twitter for more information about web development and how to improve as a developer. This article was first published on my Blog

Get a random item from an Array

Use splice() if you want to delete an element from an array

Use map() when looping through arrays

Stop using "=="

Get a random number

The trim() method

The isFinite() method

The toFixed() method

This is a way you can empty an array in JavaScript

Destructuring

I hope found this useful and if you did please let me know. If you have any questions feel free to DM me on Twitter.

Top comments (6)

Collapse
 
sebbdk profile image
Sebastian Vargr • Edited

Please do not use map instead of forEach as a rule.

Map only makes sense if you are mapping.

This is easily misunderstood by beginners i my experience. :)

Collapse
 
zachfotis profile image
Fotios Zachopoulos

Totally agree!

Collapse
 
safventure11000 profile image
Josafe Balili

Yep πŸ‘

Collapse
 
jalbertsr profile image
Joan Albert Segura

Doing myArray.length = 0; is not the way, just go with [], easier, more performant and less error-prone.

I also think that .map instead of .forEach or for is incorrect, you should use the last two to loop arrays and the .map only if you want a new array instance, by the way .map is very slow.

Collapse
 
ironcladdev profile image
Conner Ow

Wow, man. Amazing article and tips!
I'll be sure to use these a lot!

Collapse
 
pascavld profile image
Pasca Vlad

glad to hear that you liked this mate