Jeavons: Dolby: i am probably almost there, just fail to wrap my head on why we can defined objects with both data and functions same time, and then use this for the cloning
Samain: Sl33k: are you still trying to think in terms of Java?
Trendell: Sl33k: because don’t do that. Forget Java exists at all. If you try to think in terms of Java, you won’t be able to understand JavaScript
Thorstenson: JavaScript’s OO model is different from most other languages. The only language that is well-known and has a similar OO model is Lua.
Tattershall: Something like var dog = {breed: “alsatian”, makeNoise: function{console.log”bark””}}. Then clone object. var puppy = Object.createdog; puppy.makeNoise
Amunrud: Sl33k: you can do that because that’s how the person who came up with this OO model decided things would work.
Mahala: Sl33k: they wanted something where each object defines all of its behaviour all of its data, and all of its methods, and where you can easily make new objects by cloning existing ones and modifying them.
Byal: Sl33k: if you want to know why they thought that was a good idea, it’s described in the Self paper: http://bibliography.selflanguage.org/self-power.html
Marcil: Dolby: if i ignore OOP in its entirety. how then do you create similar objects ****genous. Some pattern would be needed. e.g in an app where you need to create and store “Book”
Bidle: Sl33k: java oop !== oop
Bidle: You can still have oop without thinking in terms of java
Condiff: Java is very far from anything we could call OOP, indeed.
Nordmeyer: Sl33k: if you want the same object, then you already have it!
Sabat: Sl33k: if you want something that looks like one object, but has a few additional/different properties, you clone it and modify the clone.
Segarra: Sl33k: just think in terms of objects.
Gingues: Dolby: is clone a keyword or you just mean Object.createtemplateObject? Hence, i can have a var templateObject with properties set to decent defaults
Consolazio: Sl33k: “clone” is a concept. Object.createsomeExistingObject implements that concept.
Prescott: Sl33k: you still shouldn’t be thinking in terms of cl***es. There’s no such thing as “templateObject” in prototype-based languages.
Lynskey: Dolby: with Object.create, i dont even need to use the “prototype” keyword, except when I need to add new methods to the templateObject, right?
Grigaliunas: Sl33k: all your objects should be perfectly usable, out of the box, even if they don’t do many useful things.
Nagle: Sl33k: there’s no “prototype” keyword in JavaScript. Functions have a “prototype” property, but that’s just a regular property, there’s nothing special about it
Mcsharry: Dolby: templateObject is what I would you use to create new similar objects
Gunthrop: Sl33k: that’s just an object, there’s nothing related to template/defaults/whatever in it
Frazee: Anybody running vim on windows?
Aschbacher: Xatenev are you running it under Cygwin?
Millsap: Dolby: if you are writing codes to create three books so you can add to an imaginative cart with method add. e.g cart.addbook1, book2, book3; i would want to make sure all the books are same for lack of a better word, type
Raisley: Dolby: i can message you if you are not too busy
Dibello: Sl33k: is var a = { title: “Foo”, ISBN: “bar”, author: “qux” } any different from function fooa, b, c{ return { title: a, ISBN: b, author: c }}; foo”Foo”, “bar”, “qux” or cl*** Booka, b, c{ this.title = a; this.ISBN = b; this.author = c; } new Book”Foo”, “bar”, “qux”?
Colatruglio: Sl33k: there you have your answer, then :
Dudzic: Dolby: but please hold on.
Leviner: Wait, ‘cl***’ is a keyword in javascript?
Jover: Sl33k: it doesn’t matter *how* objects are created, the only thing that matters is *what* they can do. This goes for all OO languages in fact, OO has nothing about “cl***es”.
Strawhorn: Claucherty: unfortunately, in ES6. But the examples above aren’t JS