Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Writing type conversions Date: Tue, 24 Nov 2020 11:48:22 +0000 Organization: A noiseless patient Spider Lines: 30 Message-ID: <87ft4zasc9.fsf@bsb.me.uk> References: <87eekjrfz0.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="af43d4f48e27ea0e6f4a2239942bca67"; logging-data="14947"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19U3h3LvNluMrIrbeDHWxL5QQ5fx2OWj+s=" Cancel-Lock: sha1:jPijRcgmb5scn7b3/oYF5c3eHNA= sha1:6ER1j7ab8UMPhLvgZKfv1Bg3H6c= X-BSB-Auth: 1.90838ff958202ad83717.20201124114822GMT.87ft4zasc9.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:39185 Arno Welzel writes: > Ben Bacarisse: > >> John G Harris writes: >> >>> On 23 Nov 2020 12:29:27 GMT, ram@zedat.fu-berlin.de (Stefan Ram) >>> wrote: >>> >>> >>>> However, in the Java world many deemed »+ ""« to be bad >>>> style because it does not express the intent of the >>>> programmer to convert something to a string but would >>>> mystify the reader. I do not share this point of view, >>>> however, because I think the intent of »+ ""« is clear. >>> >>> "" + x + 1 >>> makes it more obvious. >> >> Am I missing a joke? (It does something else altogether.) > > No - this is not a joke. Since JavaScript is loosely typed, the > expression "" + x + 1 is totally valid I know. I was asking if I was missing a joke in the suggestion that "" + x + 1 is a more obvious way to write +x + 1 + "". They do different things. -- Ben.