Path: csiph.com!weretis.net!feeder4.news.weretis.net!news.albasani.net!.POSTED!softins.co.uk!not-for-mail From: tony@mountifield.org (Tony Mountifield) Newsgroups: comp.lang.javascript Subject: Re: Can somebody explain this code Date: Wed, 23 Mar 2016 23:46:33 +0000 (UTC) Organization: Software Insight Ltd., Winchester, UK Lines: 49 Message-ID: References: X-Trace: news.albasani.net qIwkWI07BKH6qkVKRHF9n17U0fhD4Ryo6PSJD0FUfAtc62PyNHqdY9T63u2X774LOPgLW8DC/u7NB6CFOblRGA== NNTP-Posting-Date: Wed, 23 Mar 2016 23:47:30 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="ggJov7XzRom0vfOdHjNgdL3u6+ggfb0jfN4TC0S78+s6jrS8diqFuW2jQc555NdCA0Fv/rWIZPLFI6gIZhKF8/IveaV5DJsR03/yuSJwNHNwV1uwq89Pbc/gBZwbOdA6"; mail-complaints-to="abuse@albasani.net" Originator: tony@softins.co.uk () X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Cancel-Lock: sha1:yLpXBZBr51AUn8IsrGGv9SGANeQ= Xref: csiph.com comp.lang.javascript:30090 In article , Tony Johansson wrote: > I know that functions behave much like variables such as > var myFunc = function() { alert("This is my anonymous function");} > > But in the code below when I have (a && b)(); only function b is called and > when I have (a || b)(); only function a is called > > If a = null in this example (a || b)(); then b is called. > > Can somebody explain what is happening here when I have this kind of strange > looking code. > I do this just because of some testing how it works. > > If both a and b is null I get error because then the expression does not > produce a function value which is correct. > > > > //Tony Cheers Tony (another one!) -- Tony Mountifield Work: tony@softins.co.uk - http://www.softins.co.uk Play: tony@mountifield.org - http://tony.mountifield.org