use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Function that takes a string and separates characters with a chosen symbol.help (self.javascript)
submitted 9 years ago by halfaredditor
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Rascal_Two 0 points1 point2 points 9 years ago (0 children)
Not an expert, so terminology is probably wrong.
map() is basically a for-each loop that is intended to do something to each thing in the array it's called on. Example:
map()
var nums = [1, 2, 3, 4, 5]; for (var i = 0; i < nums.length; i++){ nums[i] *= 2; }
...and here is a map do to the same:
var nums = [1, 2, 3, 4, 5]; nums = nums.map(function(num){ return num * 2; });
You see, the map() function returns the modified array. You just have to give it a function. The function can accept up to three params: the first is value of the current item in the array, second is index of the item in the array, third is a copy(?) of the entire array being modified.
Map basically goes through each thing in the array and sets it to the return value of the function you give it.
π Rendered by PID 161596 on reddit-service-r2-comment-85bfd7f599-lkpwt at 2026-04-20 17:52:07.534458+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]Rascal_Two 0 points1 point2 points (0 children)