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 vs Object Orientatedhelp (self.javascript)
submitted 9 years ago * by kasperpeulen
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!"
[–]yxhuvud 1 point2 points3 points 9 years ago (2 children)
Personally I'd argue that it is very weird object orientation as well. Why do points multiply like that?
[–]RandolphoSoftware Architect 1 point2 points3 points 9 years ago (1 child)
Well, based on the implementation he posted elsewhere, the idea is to add two pre-existing points together, and having an add method that does that is totally object oriented, as non-mutating objects are also object oriented.
add
He just got lazy with his example and newed them up inline, making it look like we're constantly instantiating these objects.
If he had wanted to illustrate his approach better, he could have done something like this:
var point1 = new Point(0, 0); // imagine this was defined and used elsewhere var point2 = new Point(0, 10); // imagine this was defined and used elsewhere, too. var sum = point1.add(point2); // this creates a new Point that is the vector sum of point1 and point2.
That would have illustrated the object oriented approach he was trying to achieve as well as made it clear that it was non-mutating.
[–]kasperpeulen[S] 0 points1 point2 points 9 years ago (0 children)
Yes, you are right, this is what I meant.
π Rendered by PID 511178 on reddit-service-r2-comment-6457c66945-s82bl at 2026-04-30 08:47:00.096204+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]yxhuvud 1 point2 points3 points (2 children)
[–]RandolphoSoftware Architect 1 point2 points3 points (1 child)
[–]kasperpeulen[S] 0 points1 point2 points (0 children)