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


Groups > comp.lang.javascript > #13569 > unrolled thread

Syntax question '/a-b;'

Started by"Joey@still_Learning.invalid" <Joey@still_Learning.invalid>
First post2012-04-24 09:50 -0700
Last post2012-04-26 14:56 +0100
Articles 4 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  Syntax question '/a-b;' "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2012-04-24 09:50 -0700
    Re: Syntax question '/a-b;' "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-04-24 19:59 +0300
      Re: Syntax question '/a-b;' "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2012-04-24 11:32 -0700
        Re: Syntax question '/a-b;' Swifty <steve.j.swift@gmail.com> - 2012-04-26 14:56 +0100

#13569 — Syntax question '/a-b;'

From"Joey@still_Learning.invalid" <Joey@still_Learning.invalid>
Date2012-04-24 09:50 -0700
SubjectSyntax question '/a-b;'
Message-ID<79mdp71k9r37eeeurnhcif3ecfvh9vbbu7@4ax.com>
I'm looking at a js script and I've come across syntax that's foreign in
meaning to me. Could someone explain what

width = width/2-150;

Means? I don't understand what the 2-150 is all about, but when I change
the 150, my 'stuff' renders differently.
-- 
Joey

[toc] | [next] | [standalone]


#13572

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2012-04-24 19:59 +0300
Message-ID<jn6m63$avi$1@dont-email.me>
In reply to#13569
2012-04-24 19:50, Joey@still_Learning.invalid wrote:

> I'm looking at a js script and I've come across syntax that's foreign in
> meaning to me. Could someone explain what
>
> width = width/2-150;
>
> Means?

As in normal arithmetics, division has priority over subtraction, so the 
right-hand side is equivalent to (width/2) - 150.

So the width is divided by two, 150 is subtracted from the result, and 
the result of this is assigned back to the variable width.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#13577

From"Joey@still_Learning.invalid" <Joey@still_Learning.invalid>
Date2012-04-24 11:32 -0700
Message-ID<kbsdp7pce0b7ijh0se4in16bplsh2b8ent@4ax.com>
In reply to#13572
Jukka K. Korpela wrote:

>2012-04-24 19:50, Joey@still_Learning.invalid wrote:
>
>> I'm looking at a js script and I've come across syntax that's foreign in
>> meaning to me. Could someone explain what
>>
>> width = width/2-150;
>>
>> Means?
>
>As in normal arithmetics, division has priority over subtraction, so the 
>right-hand side is equivalent to (width/2) - 150.
>
>So the width is divided by two, 150 is subtracted from the result, and 
>the result of this is assigned back to the variable width.

Thank you. I'm at a loss to understand why I had to ask such a dumb
question. 
-- 
Joey

[toc] | [prev] | [next] | [standalone]


#13609

FromSwifty <steve.j.swift@gmail.com>
Date2012-04-26 14:56 +0100
Message-ID<dukip717fcvv7gb2656g58bspa46mbjt2d@4ax.com>
In reply to#13577
On Tue, 24 Apr 2012 11:32:09 -0700, "Joey@still_Learning.invalid"
<Joey@still_Learning.invalid> wrote:

>I'm at a loss to understand why I had to ask such a dumb
>question.

It was an excellent question. It solved your problem in one attempt.

-- 
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web