Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29830
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Refer object within itself |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | (9 earlier) <nb4liq$kat$1@dont-email.me> <XnsA5BECFDEEEC11eejj99@194.109.6.166> <nbdag0$ggd$1@dont-email.me> <XnsA5C292470C038eejj99@194.109.6.166> <00d49959-20f9-43ec-8d80-dc2d3991a31c@googlegroups.com> |
| Date | 2016-03-06 11:59 +0100 |
| Message-ID | <XnsA5C379E8FC4CDeejj99@194.109.6.166> (permalink) |
Scott Sauyet <scott.sauyet@gmail.com> wrote on 05 Mar 2016 in
comp.lang.javascript:
> Evertjan. wrote:
>> Aleksandro wrote:
>
>>> But it did the job. :)
>> [ ... ]
>> The answer was inexact and so unfit for this NG, where many others
>> could be set on the wrong foot.
>> [ ... ]
>
> Evertjan,
>
> I don't know where this is coming from.
Silly, it come from me, as you clearly quote!
> As Stefan pointed out, the
> answer from Ram Tobolski was the best one supplied,
An absolute "the best one"???????????? [see below]
> better than mine,
> better than the ones from Christoph Becker and Thomas Lahn. All of us
> had solutions that would do the job, but Ram's answer did the job and
> was the most simple. Thomas Lahn, was unsurprisingly the most
> comprehensive in suggesting possible approaches, but even his simplest
> one was more complex than Ram's suggestion.
>
> The OP did not specifically ask for a solution with a configurable
> `height` property, but it's a very, very obvious extension to Ram's
> answer. If the OP wasn't sure and didn't test, an quick question
> would have confirmed that it would work as expected.
>
> So, can you see anything wrong with this suggestion, or with the
> slight extension proposed by Stefan?
I agree, it was the best iyho, but not in imho.
var foo { "name":"bar", "width":600 };
foo.height = foo.width * 2;
... makes results in what is real usefull,
as it does not suffer from the error possibillity,
if someone later wants to change foo.height.
if foo.height is just a 'getter', a later:
foo.height = foo.width * 3;
using 'getter' would throw unexpectedly:
>// Uncaught TypeError: Cannot set property height of #<Object>
>// which has only a getter
which imho does not getter better.
The 'getter' method is nice and usefull,
but less simple and more error-prone,
as most shortcut codes are.
Mixing 'getters' with ordinary object properties,
would perhaps need a naming-convention that alerts the unwary,
like:
var foo = {
'nameProperty':'bar',
'widthProperty':600,
get heightGetter(){return this.width * 2;}
};
Thomas c/should come up with a better naming-convention.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Refer object within itself Andrew Poulos <ap_prog@hotmail.com> - 2016-02-26 22:50 +1100
Re: Refer object within itself Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-26 04:51 -0800
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-02-26 14:15 +0100
Re: Refer object within itself "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-02-26 16:43 +0100
Re: Refer object within itself Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-26 19:25 +0100
Re: Refer object within itself Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-26 19:23 +0100
Refer object within itself Ram Tobolski <ramtob@gmail.com> - 2016-02-28 10:06 -0800
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-02-28 23:07 +0100
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-02-28 23:23 +0100
Re: Refer object within itself Stefan Weiss <krewecherl@gmail.com> - 2016-02-29 00:11 +0100
Re: Refer object within itself Aleksandro <aleksandro@gmx.com> - 2016-02-29 14:49 -0300
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-02-29 19:49 +0100
Re: Refer object within itself Aleksandro <aleksandro@gmx.com> - 2016-03-01 10:48 -0300
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-01 17:22 +0100
Re: Refer object within itself Aleksandro <aleksandro@gmx.com> - 2016-03-01 15:07 -0300
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-01 20:26 +0100
Re: Refer object within itself Aleksandro <aleksandro@gmx.com> - 2016-03-04 21:53 -0300
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-05 14:22 +0100
Re: Refer object within itself Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-05 10:17 -0800
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-06 11:59 +0100
Re: Refer object within itself Ram Tobolski <ramtob@gmail.com> - 2016-03-06 10:48 -0800
Re: Refer object within itself Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-06 19:07 -0800
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-07 10:44 +0100
Re: Refer object within itself Aleksandro <aleksandro@gmx.com> - 2016-03-07 12:54 -0300
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-07 17:59 +0100
Re: Refer object within itself Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-07 13:44 -0800
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-07 22:59 +0100
Re: Refer object within itself Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-07 17:00 -0800
Re: Refer object within itself "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-08 10:24 +0100
Re: Refer object within itself Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-08 13:03 -0800
csiph-web