DEV Community

Shiva Aryal
Shiva Aryal

Posted on

JS functions that I learned this week

Today is friday and it’s the end of the week. Here are the top 5 javascript functions that I learned this week.

  • reduce() - Reduce function applied to arrays in Javascript. it takes the values in an array, from the first till the last element, and applies functionality such that it changes the array into one singular value. Hence, it reduces the array.

  • for…of iterator - the for-of iterator is similar to for loop. The for...of statement loops/iterates through the collection, and provides you the ability to modify specific items.

  • Nullish Operator - If the left hand side value is null or undefined this operator returns the right-hand side value otherwise left hand side value.for example: const value= null ?? “Hello”;

  • Spread Operator - Spread operator helps to expand the array into individual elements. So, it can be used to expand the array in a place where zero or more elements are expected.

  • Object.entries() - The Object.entries() method returns an array of a given object's own enumerable string-keyed property [key, value] pairs. This is the same as iterating with a for...in loop, except that a for...in loop enumerates properties in the prototype chain as well.

Please share what you learned this week in the comments. Let's learn together :)
#happyCoding #javascript #beginners

Top comments (6)

Collapse
 
curiousdev profile image
CuriousDev

What I have learned is, that in HTML you can use "dialog" element to create some kind of dialog window on the page, which can be opened and closed. Of course, there should be more, but this is what came to my mind.

Collapse
 
connectaryal profile image
Shiva Aryal

Awesome. Thank you for sharing. It was really helpful.

Collapse
 
sorasan profile image
Diego Fernando Mera Largo

hmmm the first thing that came in my mind is... you should be sure about when it is necessary to write comments in your code, and write the "why" of the code you are writing and not the "How it works". ^^

Collapse
 
andrewbaisden profile image
Andrew Baisden

Keep up the good work!

Collapse
 
faisalamin001 profile image
Faisal Amin • Edited

Thanks bro , it would be much better if you add examples also

Collapse
 
faisalamin001 profile image
Faisal Amin

Thank you! 😊