DEV Community

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

Posted on

53 11

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.

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

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
Saf11000

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

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs