DEV Community

Harnessing the power of Javascript's .map and .filter

Vince Campanale on August 10, 2017

Functional programming has been a hot topic as of late. JavaScript is a multi-paradigm language and one of the paradigms available to us lucky JS d...
Collapse
 
valtism profile image
Dan Wood

Thanks for the article, very well presented. Can you tell me some more about why you would use const instead of a variable?

Collapse
 
vincecampanale profile image
Vince Campanale • Edited

Thanks! I'm glad you liked it.

I'm not sure I grasp your question fully, but const is a way of declaring a variable. The reason I prefer it to var is because it offers a more reliable mechanism for instantiating variables. When a variable does not need to be reassigned within the scope it is defined in, a const variable is always preferred. Using const, you avoid common trap doors like accidental global variables, naming conflicts, and the like. Does this answer your question?

Collapse
 
valtism profile image
Dan Wood

Ah, so it is more for explicitly defining what it does than it is for memory management.

Collapse
 
chrisvasqm profile image
Christian Vasquez

This is, by far, the best explanation of how and why .filter() and .map() are useful 👏. I finally understand it.

Thanks a lot for making it, Vince!

Collapse
 
vincecampanale profile image
Vince Campanale

Glad I could help man!

Collapse
 
janguianof profile image
Jaime Anguiano

niiice!!