map passes each element of the array as a parameter to the function:
[element1, e2].map(myFunction);
String.prototype.trimis not a function that you pass in the string to be trimmed. Instead, you call the function as a method of this line:
" some string ".trim(); // "some string"
To use trimin .map, you need to do something like:
[" a ", "b", " c", "d "].map(function(e){return e.trim();});
source
share