Most used methods in javascript to know to deal with problems

Hi coders !!!,

I want to ask if there are any JavaScript methods you need to know, such as the slice method for arrays (this is an example). I ask this question because I have difficulty implementing the methods and using them correctly.

Thanks and happy coding!!! :muscle:

I’m not sure that I understand the question. Yes, we use JavaScript methods. That’s what the language is made up of.

Whenever you need something and don’t know a method to do it, just google it, most of the times the method exists

.map()
.forEach()
Object.entries()
.reduce()
.filter()
Array.from()
String()
parseInt()

Are the ones I use the most hands down.

1 Like

Thanks @kerafyrm02 I ask exactly this!!!

Definitely try to get the hang of .reduce() --it’s an amazingly powerful method. Start with implementing Math.max with it, then try your hand at implementing .map() and .filter().

1 Like
  • Strings: padStart/padEnd for formatting numeric strings.
  • Dates: toLocaleString for formatting dates (it is extremely flexible).
  • Browser API: async/await
  • Destructuring for grabbing object properties. Cannot emphasise enough how useful this is once it becomes muscle memory and you just automatically use it.
  • map, filter, includes, every, join for arrays.
  • It is imo important to understand reduce well, because almost every other array method can be implemented using it. I used to use it a lot for changing the shape of data in lists, but it tends to be difficult to [easily] follow the code once you get past very simple usecases. So instead of reduce, or cases where I need to [say] filter then map then do something else generally use:
  • for...of loops.
  • Rest/spread, in particular [...someArray] for copying arrays and {...someObject} for copying/non-destructively updating objects.
1 Like