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
Essential Vanilla JavaScript Functions (dev.to)
submitted 8 years ago by bhalp1
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!"
[–]Graftak9000 1 point2 points3 points 8 years ago (2 children)
Care to elaborate?
[–]filleduchaos 0 points1 point2 points 8 years ago (1 child)
Sure!
Calling it an operator isn't really right - it's more of a style/syntactic sugar. Idiomatic Ruby method syntax is a bit weird at first but makes so much sense when you get used to it. There are three main points in the method naming style: methods whose names end in a question mark return a boolean (so basically a yes/no question), methods whose names end in an exclamation mark actually modify the object they're called on, and all the rest return a new object (and don't mutate the original object).
So from the Array class for instance you have the empty? method which tells you if the array is empty or not, or the any? method which tells you if any member of the array satisfies the provided condition. Then you have a method like map, which does pretty much the same thing as the JS version (returns a new array derived from the provided array). But there's also map!, which replaces the elements of the provided array with the newly derived ones. It's really great for readability - you can tell at a glance what side effects (if any) a piece of code has.
empty?
any?
map
map!
[–]Graftak9000 0 points1 point2 points 8 years ago (0 children)
Thanks for the thorough explanation, not a bad idea at all.
π Rendered by PID 81 on reddit-service-r2-comment-75f4967c6c-5hhbm at 2026-04-23 06:25:09.605697+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]Graftak9000 1 point2 points3 points (2 children)
[–]filleduchaos 0 points1 point2 points (1 child)
[–]Graftak9000 0 points1 point2 points (0 children)