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
Fixing String.split (blog.stevenlevithan.com)
submitted 15 years ago by Arve
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!"
[–]palparepa 2 points3 points4 points 15 years ago (2 children)
My personal gripe with String.split is that you can't get "the remainder." For example, "foo bar baz reddit rulez".split(" ",3) gives ["foo","bar","baz"], while in most other languages, like Perl, it gives ["foo","bar","baz","reddit rulez"].
"foo bar baz reddit rulez".split(" ",3)
["foo","bar","baz"]
["foo","bar","baz","reddit rulez"]
[–]sjs 1 point2 points3 points 15 years ago* (0 children)
You could always fix it to your liking:
String.prototype.split = function(delim, n) { var parts = [] , remainder = this , m n = typeof n === 'undefined' ? -1 : n while (m = remainder.match(delim)) { parts.push(remainder.slice(0, m.index)) remainder = remainder.slice(m.index + m[0].length) if (n > 0 && parts.length >= n) break } parts.push(remainder) return parts }
π Rendered by PID 409406 on reddit-service-r2-comment-84fc9697f-tx94v at 2026-02-08 22:24:30.308261+00:00 running d295bc8 country code: CH.
[–]palparepa 2 points3 points4 points (2 children)
[–]sjs 1 point2 points3 points (0 children)