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


Groups > comp.lang.javascript > #28771

Re: How to manipulate integer that sometimes Nan and sometimes have a value?

Newsgroups comp.lang.javascript
Subject Re: How to manipulate integer that sometimes Nan and sometimes have a value?
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <9060ce04-2f9e-4554-be83-2f69c213424f@googlegroups.com> <XnsA520AE7AD610Feejj99@194.109.6.166> <560bddeb$0$23841$e4fe514c@news.xs4all.nl> <XnsA525D7E5B774Eeejj99@194.109.6.166> <560cf259$0$23792$e4fe514c@news.xs4all.nl>
Date 2015-10-01 13:56 +0200
Message-ID <XnsA5268DC2F5A52eejj99@194.109.6.166> (permalink)

Show all headers | View raw


Erwin Moller <erwinmollerusenet@xs4all.nl> wrote on 01 Oct 2015 in 
comp.lang.javascript:

> On 9/30/2015 9:13 PM, Evertjan. wrote:
>> Erwin Moller <erwinmollerusenet@xs4all.nl> wrote on 30 Sep 2015 in
>> comp.lang.javascript:
>>
>>> On 9/25/2015 5:09 PM, Evertjan. wrote:
>>>> jonas.thornvall@gmail.com wrote on 25 Sep 2015 in comp.lang.javascript:
>>>>
>>>>> This is how i chosen to do it,
>>>>
>>>> To do what?
>>>>
>>>>> is there a better way?
>>>>
>>>> I am reasonably sure there is,
>>>> but that depends on the answer of the first Q.
>>>>
>>>>> if (isNaN(addOne[i])) addOne[i] = 0; addOne[i] = addOne[i]+1;
>>
>> [Above 1]
>>
>>>> This would do the same,
>>>> [using kiss, the array seems not to be a part of your Q]:
>>>>
>>>> if (isNaN(z))
>>>>       z = 0;
>>>> z++;
>>
>> [above 2]
>>
>>> (A late and barely relevant response)
>>>
>>> Just curious, are you one of those that omit curly brackets whenever
>>> possible?
>>> If yes, why?
>>
>> Why not?
>>
>> "Above 1" shows how NOT to do it.
>>
>> "Above 2" shows a perfectly reasonable way how to do it.
>>
>> Those curly things feel a bit like things that are not to be pronounced.
>>
>> Whenever possible,
>> I like to see and do the good things in and of life,
>> absolutely including programmable cyberlife,
>> and foremostly including having a good laugh about
>> those that think in near absolutes.
>>
>> That seldom is impossible.
>>
> 
> I bow in your wisdom. ;-)
> 
> This is not about what is possible, but just about clarity.
> But each to his/her own.
> 
> Here is a real life example of troubles coming with that style:
> https://blog.codecentric.de/en/2014/02/curly-braces/

Everything is dangerous in the hands of the incompetent.

the curly things are often felt as part of the if() statement,
but they are not.

Methinks cascading curly things,
excepting those on the heads of fair maidens,
are far more accident-prone than neatly indented code.

['braces' are a way of making fair maidens even more fair,
unfairly reducing that fairness to cuteness for the time being]

The curly things in JS are a only necessary when
making a single compound statement consisting of multiple statements,
and so are superfluous around single statements.

Thinking they are required around single statements when such statement 
[accidently] is the "object" of an if-statement, shows a respectable lack of 
understanding of the scripting flow.

[Ideally, imho, they should not be required around a single-statemented 
function-declaration, as a should just define the compound statement in the 
function, but helas, that wasn't to be the case.]

So:

if (a)
  if (b)
    if (c)
      doD();

... is a nice and simple form of a single compound statement.

if (a)
  {doA();
    if (b)
      if (c)
        doD();
  };

... here the curly things are only needed to make a compound substatement 
work.

if (a)
  {doA();doB();};
if (b)
  {doB();doE();};
if (c)
  {doC();};

Here I would allow the unnecessary third statement's curly things
just for symmetry's sake.

Thinking of nicely visual modularity and so for debuggability,
perhaps the "object" of a if() statement should always be a single 
statement, preferably a adequately named function.

In practice, we all, and more than never, write dirty code,
even where the debugging process nullifies the logic of the urge for 
quickness.

-- 
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


Thread

How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-25 07:31 -0700
  Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-25 17:09 +0200
    Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-25 14:43 -0700
      Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 08:54 +0200
    Re: How to manipulate integer that sometimes Nan and sometimes have a value? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-09-30 15:04 +0200
      Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-30 21:13 +0200
        Re: How to manipulate integer that sometimes Nan and sometimes have a value? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-10-01 10:44 +0200
          Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-10-01 13:56 +0200
            Re: How to manipulate integer that sometimes Nan and sometimes have a value? John Harris <niam@jghnorth.org.uk.invalid> - 2015-10-02 11:09 +0100
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-02 13:55 +0100
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-10-02 16:34 +0200
  Re: How to manipulate integer that sometimes Nan and sometimes have a value? Danny <dann90038@gmail.com> - 2015-09-25 15:11 -0700
    Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-25 17:50 -0700
      Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 08:59 +0200
        Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 04:25 -0700
          Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 15:00 +0200
            Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 06:15 -0700
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 15:34 +0200
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 08:06 -0700
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? Tim Streater <timstreater@greenbee.net> - 2015-09-26 18:10 +0100
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 22:53 +0200
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? Tim Streater <timstreater@greenbee.net> - 2015-09-26 22:37 +0100
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-27 10:05 +0200
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 08:42 -0700
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? Tim Streater <timstreater@greenbee.net> - 2015-09-27 17:18 +0100
      Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-26 10:59 +0100
        Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 13:15 +0200
          Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-26 14:58 +0100
            Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 16:57 +0200
        Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 04:28 -0700
          Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 15:11 +0200
            Re: How to manipulate integer that sometimes Nan and sometimes have a value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-26 17:19 +0200
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-26 22:51 +0200
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-27 13:50 +0200
          Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-26 20:51 +0100
            Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-28 22:45 -0700
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-09-29 12:36 +0200
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-29 12:48 +0100
        Re: How to manipulate integer that sometimes Nan and sometimes have a value? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-26 14:43 +0200
          Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-26 06:06 -0700
            Re: How to manipulate integer that sometimes Nan and sometimes have a value? John Harris <niam@jghnorth.org.uk.invalid> - 2015-09-27 14:06 +0100
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 08:50 -0700
              Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 08:53 -0700
                Re: How to manipulate integer that sometimes Nan and sometimes have a value? jonas.thornvall@gmail.com - 2015-09-27 09:02 -0700

csiph-web