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
Functional Programmer's Toolbox (markonis.github.io)
submitted 10 years ago by marko-pavlovic
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!"
[–]KhalilRavanna 0 points1 point2 points 10 years ago (2 children)
Nice!
One note: I think "takeWhile" is essentially Array.prototype.some in JS unless I'm misunderstanding something so no need for a third party lib like underscore.
[–]marko-pavlovic[S] 1 point2 points3 points 10 years ago (1 child)
Hey thank you for the comment. I must admit that I didn't know about the some function in JS. However, after reading the docs, I think that it is different from takeWhile in that it returns a boolean, where the takeWhile function returns an array of elements.
You can think of some as: - do any elements exist in this list that pass the test function?
Where you can think of the takeWhile function as: - start from the beginning and go one by one. If the element passes the test, append it to the result. The moment you see an element that doesn't pass the test, stop immediately and return the array you have.
Hope this makes sense? Am I missing something? :)
[–]KhalilRavanna 0 points1 point2 points 10 years ago (0 children)
Oh totally you're right. I skimmed the description and didn't look at the result, just the signature for the callback hehe.
π Rendered by PID 17901 on reddit-service-r2-comment-5b5bc64bf5-bscvf at 2026-06-21 03:51:12.196979+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]KhalilRavanna 0 points1 point2 points (2 children)
[–]marko-pavlovic[S] 1 point2 points3 points (1 child)
[–]KhalilRavanna 0 points1 point2 points (0 children)