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


Groups > comp.lang.javascript > #25148

Re: Javascripts help with interpretation

From Tim Slattery <tim@risingdove.com>
Newsgroups comp.lang.javascript
Subject Re: Javascripts help with interpretation
Date 2014-06-30 18:04 -0400
Organization A noiseless patient Spider
Message-ID <0kn3r95jms31nkpn2vuv14plgk02cm3amn@4ax.com> (permalink)
References <321d3d42-d0a2-4eab-9aa1-559aac68d20c@googlegroups.com>

Show all headers | View raw


jonas.thornvall@gmail.com wrote:

>Sometimes when i read code i realise my programming skils far to ancient.
> 
>return ((N<0) ? "-"+HexN : HexN);
>
>
>This function return is a string but what does ((N<0) ? actually mean 
>there is no if. And what about "-"+HexN : HexN); 

It's the ternary operator. The first part is delimited by the "?", the
second by the ":". It means: If N is less than zero, return "-"
concatenated to HexN, else return HexN unchanged.

-- 
Tim Slattery
tim <at> risingdove <dot> com

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


Thread

Javascripts help with interpretation jonas.thornvall@gmail.com - 2014-06-30 14:23 -0700
  Re: Javascripts help with interpretation Andrew Poulos <ap_prog@hotmail.com> - 2014-07-01 07:36 +1000
    Re: Javascripts help with interpretation jonas.thornvall@gmail.com - 2014-06-30 14:51 -0700
  Re: Javascripts help with interpretation Tim Slattery <tim@risingdove.com> - 2014-06-30 18:04 -0400

csiph-web