Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: I don't get it Date: Sat, 10 Apr 2021 19:08:48 +0100 Organization: A noiseless patient Spider Lines: 66 Message-ID: <87lf9qrozz.fsf@bsb.me.uk> References: <1e965vkgenq7l$.hqmrkifgr4m5$.dlg@40tude.net> <586d1b88-77d5-42b0-ae5b-7506307df499n@googlegroups.com> <957a79db-946e-4f23-931a-ef7d4f0dbb3cn@googlegroups.com> <305fecc4-43da-4378-8430-ed10ac4dbe5bn@googlegroups.com> <20917gl3dv8shs6qqf1dqginq69e50aa54@4ax.com> <8735vytcwa.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="69a28ed7f554c2fd6adcf981e90179d7"; logging-data="27283"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184JAzHGP3sy2xI+XKt+3L9t5GFGcIHvCM=" Cancel-Lock: sha1:sNjU2YwKiTVNWa1f6eeY12isW2c= sha1:yKnj0fMo2PDxsjRk8ZB8mDBKKQs= X-BSB-Auth: 1.e65696a30f2e9f9bc912.20210410190848BST.87lf9qrozz.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:39888 The Natural Philosopher writes: > On 10/04/2021 15:47, Ben Bacarisse wrote: >> The Natural Philosopher writes: >> >>> On 09/04/2021 20:01, John G Harris wrote: >>>> On Fri, 9 Apr 2021 10:03:13 +0100, The Natural Philosopher >>>> wrote: >>>> >>>> >>>>> After spending two days some years ago I discovered that IE and Firefox >>>>> differed in their handling of comparisons of numerical and string data, >>>>> and that something like >>>>> >>>>> if('1'== 1) >>>>> >>>>> was handled differently in each browser. >>>>> >>>>> As with all loosely typed languages, bugs in your code are trumped by >>>>> bugs in the language itself. >>>> >>>> Was that before or after they claimed to conform to ECMA 262? If >>>> after, one or both browsers had a bug, not the language. If before, >>>> that's what you get with USPs. >>> >>> It was around 2007 give or take. IE6 and XP was current. I coded for >>> firefox, it broke in IE6. >>> >>> I actually checked the language spec. As far as I cam remember the >>> spec was explicit, that you converted to whatever the target of an >>> assignement was in a mixed type operation, but in a conditional there >>> was no assignment type... >> >> So you looked in the wrong place. I don't think that adds much useful >> information. ECMA 262, 3rd edition (2000) is very clear about the >> conversions required by the == operator (section 11.9.1 and 11.9.3). >> For the record, the string should be converted to a number (and the >> algorithm for doing that is given in great detail too). >> >> So it's not an issue with the specification. Testing in IE6 running on >> XP I find that the conversion is done correctly. Did Mozilla really >> have such a crude bug, and if so, did you really code for that despite >> the specification being clear? >> > All I know is that IE6 and firefox gave different results and it was > down to an implicit cast in a conditional statement. The code I have > now - dated 2008, after fixing - simply turns everything explicitly > into a Number()....so I assume that firefox was doing that implicitly > and IE6 was not. I've tested it on IE6. Unless IE6 is a Heisenberg browser, it does the conversion correctly. > You can defend the language all you like - I was past caring. I'm not defending the language. > I had a job to do and IE6 and firefox produced completely different > results on the same web page, because of casting. Forcing everything > to a number whether it needed it or not fixed the issue. Maybe is was Mozilla that got it wrong, or maybe you are mis-remembering? -- Ben.