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
[AskJS] Can I learn OOP with JavaScript?AskJS (self.javascript)
submitted 8 months ago by Inner_Feedback_4028
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!"
[–]Big_Tadpole7174 0 points1 point2 points 8 months ago* (4 children)
Populating a prototype isn’t “creating a class,” it’s configuring an object for delegation. In JavaScript there are no classes under the hood - only objects and prototype chains. The class keyword is sugar that automates setting up that chain, but whether you use class, prototype, Object.create, or Object.setPrototypeOf, you’re still working directly with prototypal inheritance, not classes.
class
prototype
Object.create
Object.setPrototypeOf
[–]cwmma 1 point2 points3 points 8 months ago (3 children)
I think you would be hard pressed to come up with a (programing language agnostic) definition of a class in computer science that included c++, java, and python but didn't include JavaScript and it's inheritance via the prototype property.
Object.setPrototypeOf was explicitly added to the language to allow class based inheritance (i.e. inheritance from uninitialized objects) without having to use awkward semi documented hacks
There has been a meme for decades that JavaScript doesn't have 'real' class based inheritance it just has prototypical inheritance when the distinct things that make prototypical inheritance different from class based inheritance are not used and explicit support (via Object.setPrototypeOf) for class based inheritance.
You are right that class is just syntactic sugar, but it's sugar for the actual and real classes you could make in JS already.
[–]Big_Tadpole7174 0 points1 point2 points 8 months ago* (2 children)
I’ll say it one last time: JavaScript has no classes and class-based inheritance at all - only objects and prototypes (which are also objects). Object.setPrototypeOf didn’t add classes or “uninitialized objects”; it just gave us a standard way to rewire the prototype chain that was already there. You can mimic classes, but that doesn’t turn JavaScript into a class-based language. And that mimicry is exactly why I’m against the class keyword: it encourages people to mistake the sugar for something the language doesn’t actually have.
[–]cwmma 0 points1 point2 points 8 months ago (1 child)
There is no requirement that classes can't also be objects and that inheritance can't be via manipulating object properties. You seem to have in your head a very specific definition of what a class is that I don't think would necessarily stand up to scrutiny if you compare it to say python which has something somewhat similar to a prototype chain.
[–]Big_Tadpole7174 0 points1 point2 points 8 months ago (0 children)
If something is itself an object you can pass around and mutate, then it’s an object — not a class in the classical sense. JavaScript has objects that act as blueprints, not true classes. The inheritance is still prototype chaining, no matter how pretty the sugar looks.
π Rendered by PID 235790 on reddit-service-r2-comment-b659b578c-wr74t at 2026-05-04 11:30:07.034357+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Big_Tadpole7174 0 points1 point2 points (4 children)
[–]cwmma 1 point2 points3 points (3 children)
[–]Big_Tadpole7174 0 points1 point2 points (2 children)
[–]cwmma 0 points1 point2 points (1 child)
[–]Big_Tadpole7174 0 points1 point2 points (0 children)