In Python there is a function called map
that allows you to go: map(someFunction, [x,y,z])
and go on down that list applying the function. Is there a javascript equivalent to this function?
I am just learning Python now, and although I have been told javascript is functional language, I can see that I have been programming in a non-functional javascript style. As a general rule, can javascript be utilized as a functional language as effectively as Python can? Does it have similar tricks like the map
function above?
I've also just begun an SML course and am wondering how much of what I learn will be applicable to javascript as well.
.map()
and it's a method on the Array prototype. – Pointy Nov 8 at 3:19map(f,[])
you do[].map(f)
. But js is also functional in the sense that just like Python you can implement the functionmap(f,[])
in javascript. Map is not what makes Python functional. It's the ability to write themap
function that makes it functional - it just so happens that the standard library has one provided. – slebetman Nov 8 at 3:48lisp
,scheme
,haskel
). It has some capabilities, but -- it's not really optimized for that... – mgilson Nov 8 at 3:49