Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16203

Re: Who's eaten my apple and why?

From Stefan Weiss <krewecherl@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Who's eaten my apple and why?
Date 2012-09-27 22:06 +0200
Organization albasani.net
Message-ID <k42bjb$6v6$1@news.albasani.net> (permalink)
References <37c94a7b-70f8-47f5-b5b8-2a1b3350de43@u19g2000yqo.googlegroups.com> <k403fb$o5g$1@speranza.aioe.org> <8dedf519-0485-431a-b46e-58707db5af27@l14g2000yqo.googlegroups.com> <k40bfe$d00$1@news.albasani.net> <0965307b-3a7b-42e9-b58c-a5b73895453b@e18g2000yqo.googlegroups.com>

Show all headers | View raw


On 2012-09-27 04:44, justaguy wrote:
> Does  opt.text = opt.value = Os[i]; equal to
>  opt.text = Os[i];
>  opt.value = Os[i];
> ?
> It appears so.  Could you give a practical example of such usage? (as
> you mentioned in this case it's not necessary to set the value.

I thought that was a practical example ;)

You can use 'a = b = c = 42' whenever you want to assign the same value
to more than one variable or property. The values will be assigned from
right to left:
  - precedence made explicit: a = (b = (c = 42))
  - the expression c = 42 is evaluated first, and returns 42
  - that result is assigned to b, and the assignment returns 42 again
  - that result is then assigned to a

If you do this with variables, be careful to declare them first. This is
a common mistake:

  function makeRedBlock () {
      var color = "red",
          height = 20,
          width = length = 10;
      //...
   }

This will assign the values as intended, but 'length' has not been
declared and will end up as a global.

- stefan

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Who's eaten my apple and why? justaguy <lichunshen84@gmail.com> - 2012-09-26 14:43 -0700
  Re: Who's eaten my apple and why? Christoph Becker <cmbecker69@gmx.de> - 2012-09-27 01:35 +0200
    Re: Who's eaten my apple and why? justaguy <lichunshen84@gmail.com> - 2012-09-26 17:46 -0700
      Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 03:51 +0200
        Re: Who's eaten my apple and why? justaguy <lichunshen84@gmail.com> - 2012-09-26 19:44 -0700
          Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 22:06 +0200
    Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-26 17:59 -0700
      Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 04:16 +0200
        Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-26 19:38 -0700
          Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 05:44 +0200
            Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 09:28 -0700
              Re: Who's eaten my apple and why? Tim Streater <timstreater@greenbee.net> - 2012-09-27 17:40 +0100
                Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 16:24 -0700
              Re: Who's eaten my apple and why? Dr J R Stockton <reply1239@merlyn.demon.co.uk.invalid> - 2012-09-29 20:47 +0100
          Re: Who's eaten my apple and why? Christoph Becker <cmbecker69@gmx.de> - 2012-09-27 13:00 +0200
            Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 09:34 -0700
              Re: Who's eaten my apple and why? Christoph Becker <cmbecker69@gmx.de> - 2012-09-27 19:14 +0200
                Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 21:40 +0200
                Re: Who's eaten my apple and why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-28 15:39 +0200
                Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 16:25 -0700
      Re: Who's eaten my apple and why? Tim Streater <timstreater@greenbee.net> - 2012-09-27 08:52 +0100
  Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-26 17:50 -0700

csiph-web