Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: understanding the expression "ws && ~[2, 3].indexOf(ws.readyState)" Date: Sat, 28 Jan 2017 15:33:38 +0000 Organization: A noiseless patient Spider Lines: 27 Message-ID: <874m0jurl9.fsf@bsb.me.uk> References: <878tpwzqct.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="48548a773e1b9bbc916cd17ab98cd158"; logging-data="24979"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/O8g0eu4LT/9m4yaCLDoe83FsvhCc5hgc=" Cancel-Lock: sha1:Au2V3Lr0w9PTUXuZDfjyhrYwygA= sha1:gEMZLqmpeBtootZ59z4fqh66a/Y= X-BSB-Auth: 1.630c890a1adf2d300ce3.20170128153338GMT.874m0jurl9.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:32407 "Evertjan." writes: >> Le 27/01/2017 … 12:36, Ben Bacarisse a ‚crit : >>> Any non-zero number (other than NaN) is considered to be true in a >>> Boolean context. > > Please reconsider: What should I be re-considering? > alert(0 == false) // true > alert(0 === false) // false > > alert(17 == true) // false ??????????? > alert(true == 17) // false ??????????? > alert(!!17) // true There is only one example of a non-zero number in a Boolean context there and it behaves as I described. Maybe I should have been explicit about what I meant by a Boolean context. It's where the abstract toBoolean operation is used in the language specification. -- Ben.