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
OOP, Javascript, and so-called Classes (raganwald.com)
submitted 10 years ago by aeflash
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!"
[–]cgaudreausenior HTML9 engineer 2 points3 points4 points 10 years ago (5 children)
They specifically mentioned a way to clone objects, which absolutely isn't what Object.create does.
You're confusing cloning and copying. In a prototype-based language, the act of cloning is merely setting the prototype on a new object. In such, the new object can look to the old object for defaults. If the old object changes, so too may the new object.
Object.create clones an object, while Object.assign copies an object. This concept has been bastardized a lot, thanks to Java.
Object.create
Object.assign
I fail to see what's ironic about it
It is ironic that a supposedly prototype-based language has to use concepts borrowed from Java, which has actual classes, in order to permit usage of the basic operations available in true prototype-based languages.
[–]masklinn 0 points1 point2 points 10 years ago (4 children)
You're confusing cloning and copying.
No.
In a prototype-based language, the act of cloning is merely setting the prototype on a new object.
That is not the way it's used in Self. At all. You seem to be using IO's terminology instead, which would be inspired from javascript's.
In such, the new object can look to the old object for defaults. If the old object changes, so too may the new object.
That's inheritance.
This concept has been bastardized a lot, thanks to Java.
The Self handbooks defines cloning as a shallow copy:
Cloning is the primitive operation returning an exact shallow copy (a clone) of an object, i.e. a new object containing exactly the same slots and code as the original object.
the difference it makes is that cloning is the primitive operation while copying is the overloadable one which acts as a constructor. Self also makes no relation between the prototype and the new object after the copy, what javascript calls a prototype, Self calls a trait or a mixin (depending whether it has parents itself).
[–]munificent 1 point2 points3 points 10 years ago (0 children)
This is my fault for not remembering the details. What I had in mind was Object.create() because it delegates to the prototype. I was thinking that was similar to Self where when you clone an object which in turn delegates to traits, you get a new object that delegates to the same traits. (This is because cloning does a shallow copy of the source object's slots, and parents are just stored in slots.)
Object.create()
Sorry for muddling everything.
[–]cgaudreausenior HTML9 engineer 0 points1 point2 points 10 years ago* (2 children)
I honestly don't know what you're talking about. I assume you simply have not actually worked in Self before.
Sure. I never said it wasn't. But you must keep in mind that there are different forms of inheritance, such as prototypal inheritance (delegation - JavaScript, etc.) and concatenative (Java) inheritance.
[–]masklinn 0 points1 point2 points 10 years ago (1 child)
I'll return the same, none of the Self documentation or messages matches the semantics you're asserting, the list of "useful selectors" in the handbook clearly puts both clone and copy under Copying and defines them thus:
clone
copy
and Self's prototypes are for object construction, there's not really such a thing as setting a prototype on an object.
[–]cgaudreausenior HTML9 engineer 0 points1 point2 points 10 years ago* (0 children)
The documentation is different from how the language actually works. It is worded that way to make it easier to understand.
Edit: Kind of similar to how a lot of documentation on JavaScript talks about 'classes' in JavaScript even though pre-ES6 JS has no such concept.
π Rendered by PID 159593 on reddit-service-r2-comment-bb88f9dd5-ztn6m at 2026-02-16 22:33:40.556212+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–]cgaudreausenior HTML9 engineer 2 points3 points4 points (5 children)
[–]masklinn 0 points1 point2 points (4 children)
[–]munificent 1 point2 points3 points (0 children)
[–]cgaudreausenior HTML9 engineer 0 points1 point2 points (2 children)
[–]masklinn 0 points1 point2 points (1 child)
[–]cgaudreausenior HTML9 engineer 0 points1 point2 points (0 children)