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


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

Simple question on boolean function return value

Started byJanis Papanagnou <janis_papanagnou@hotmail.com>
First post2023-01-13 15:56 +0100
Last post2023-01-28 09:05 -0800
Articles 3 — 2 participants

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


Contents

  Simple question on boolean function return value Janis Papanagnou <janis_papanagnou@hotmail.com> - 2023-01-13 15:56 +0100
    Re: Simple question on boolean function return value Janis Papanagnou <janis_papanagnou@hotmail.com> - 2023-01-13 16:23 +0100
    Re: Simple question on boolean function return value V V V V V V V V V V V V V V V V V V <vvvvvvvvaaaaaaaaaaaaaaa@mail.ee> - 2023-01-28 09:05 -0800

#41165 — Simple question on boolean function return value

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2023-01-13 15:56 +0100
SubjectSimple question on boolean function return value
Message-ID<tprrfh$4ve$1@gioia.aioe.org>
Today I was surprised that some old code did not work as I'd have
expected:

function friday_13th (now)
{
  return  now.getDay()==5 && now.getDate==13;
}

That function returned 'false' and also putting parenthesis around
the (sub-) expressions did not help. I had to use a local variable
to make that work:

function friday_13th (now)
{
    var f13 = now.getDay()==5 && now.getDate()==13;
    return  f13;
}

Can anyone explain that please?

Janis

[toc] | [next] | [standalone]


#41167

FromJanis Papanagnou <janis_papanagnou@hotmail.com>
Date2023-01-13 16:23 +0100
Message-ID<tprt13$vkf$1@gioia.aioe.org>
In reply to#41165
On 13.01.2023 16:09, Stefan Ram wrote:
> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>> return  now.getDay()==5 && now.getDate==13;
> 
>   There is a pair of parentheses missing above.

Argh! - I had been looking so long at that code that I obviously
got "code-blind". - Thanks!

Janis

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


#41185

FromV V V V V V V V V V V V V V V V V V <vvvvvvvvaaaaaaaaaaaaaaa@mail.ee>
Date2023-01-28 09:05 -0800
Message-ID<750ecf88-693a-4da4-891b-625a3375afc8n@googlegroups.com>
In reply to#41165
P i c t u r e , ⠀⠀⠀p a r d o n ?





On Friday, January 13, 2023 at 4:56:58 PM UTC+2, Janis wrote:
> Today I was surprised that some old code did not work as I'd have 
> expected: 
> 
> function friday_13th (now) 
> { 
> return now.getDay()==5 && now.getDate==13; 
> } 
> 
> That function returned 'false' and also putting parenthesis around 
> the (sub-) expressions did not help. I had to use a local variable 
> to make that work: 
> 
> function friday_13th (now) 
> { 
> var f13 = now.getDay()==5 && now.getDate()==13; 
> return f13; 
> } 
> 
> Can anyone explain that please? 
> 
> Janis

[toc] | [prev] | [standalone]


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


csiph-web