Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Trying to understand OOP, Umpteenth time Date: Fri, 5 Jan 2018 15:48:18 +0100 Organization: solani.org Lines: 15 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1515163697 4149 eJwNycERACEIA8CWgiE4lKNw9F+Ct98Vw6K2h8I1GsS66rRrQ3S2im6bf3w6LM8DuMRB3l6oBw1gEIg= (5 Jan 2018 14:48:17 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Fri, 5 Jan 2018 14:48:17 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 X-User-ID: eJwFwQERACAIA8BKCmyTOMhh/wj+w7nZCoKBh7fahs3qq9Kljj1t0HOlw0YxrX2iDAvZXh8WdhB3 Cancel-Lock: sha1:Dtyra3vk8l5YldCYONDN8naXCwE= Content-Language: de-DE In-Reply-To: X-NNTP-Posting-Host: eJwFwYEBwCAIA7CXxELVcxiF/09YEqCxjjPoMTHMdzcNs+AFuWTG3F6pvoURTlevK4r43vkBGdARYg== Xref: csiph.com comp.lang.javascript:34457 On 05.01.2018 at 15:10, bit-naughty@hotmail.com wrote: > OK, so I think I get it. If you have a class X (OK, you can't, but maybe by now you can...ugh! I donno, you get my point?), you can say var foo = new X() ; ,and then you can execute stuff *inside* X like this: foo.m() ;. > > But then you can also do var bar = new X();, and then you'd have a second instance of X, right? My question is WHY? Why would you need the same thing twice?? ie. in short, what is the whole POINT of doing OOP? Where would you NEED to do the var bar stuff, after you'd already done the var foo? new classname() creates a new object instance, what is quite comparable to a baking machine producing a bread. If there should be more than one bread, you have to press the button again. This again is quite similar to a car factory, which will produce many cars (not only a single one). If you want to shiftGear(), accelerate() or brake() a certain car, the others should not be affected, of course. -- Christoph M. Becker