📜 ⬆️ ⬇️

The era of octal numbers ends with a leading zero in JavaScript

The parseInt ("042") === 42 equality (as well as others like it) will become true in Firefox of the next version (Firefox 21) and in newer ones, although Firefox previously acted in the image and likeness of C, considering octal numbers started with zero - so the call parseInt ("042") then gave the value 34 .

The discussion in Mozilla's bugzilla shows that this change occurred under the influence of ECMAScript 5 and corresponds to changes that occurred in other browsers (Safari 6, Google Chrome 23, etc.), in the V8 engine (and in Node.js based on it, for example), so this year, Firefox remained the last bastion of octalism.

Now this stronghold could not resist, this stronghold fell. Update your sites as needed, especially if they dealt with the processing of time records , where numbers with a leading zero often come across.

')

Source: https://habr.com/ru/post/178271/


All Articles