
{} - 1 and 1 - {} to {{} - 1} and {1 - {}}. (Newer versions of Node.js changed the parsing rules, so that {} is not a block unless there is evidence for a block context, such as the added braces or a semicolon.)n is a negative integer” to “if n is a negative odd integer”'0', '1', '2', and so on in increasing order. They are followed by the remaining keys, in the order of insertion.”for (const i of greeting) to for (const i in greeting)for (i in arr) { if (i + 1 === 10) console.log(a[i]) }
to
for (const i in arr) { if (i + 1 === 10) console.log(arr[i]) }
for (let i = 0; i < a.length - b.length; i++)to
for (let i = 0; i <= a.length - b.length; i++)
; n++ after the second sum += valuenew expression is that returned value, not the newly created object.” to “Do not return any object from a constructor function. Otherwise the value of the new expression is that returned object, not the newly created object.”new expression still returns the newly created object.” to “If the constructor returns an object, it becomes the value of the new expression. Otherwise, the return value is ignored and the new expression yields the constructed object.”button.addEventListener('click', function () {
this.classList.toggle('clicked')
})
to
button.addEventListener('click', event => {
this.classList.toggle('clicked')
})
You may wonder (as some eagle-eyed readers did) why the original code worked. Shouldn't this be undefined in a nested function? Yes, but the addEventListener method goes through a heroic effort to set this when it is passed a function.
x.toExponential(4) // '1.667e-3'to
x.toExponential(4) // '1.6667e-3'
'1.667e-3' to '1.6667e-3', and “The range of all floating-point numbers” to The range of all positive floating-point numbers. . . after the first valuesmoonlanding.toLocaleDateString() // '20.7.1969' if the locale is German
moonlanding.toLocaleDateString('en-US') // '7/20/1969'
to
moonlanding.toLocaleDateString() // '20.7.1969' with German locale and time zone
moonlanding.toLocaleDateString('en-US') // '7/20/1969' or '7/21/1969', depending on the time zone
! to the string, i.e. 'Hi 🌐!'.codePointAt(i)const phrase = 'à coté de' const prefix = 'https://www.linguee.fr/anglais-francais/traduction' const suffix = '.html' const url = prefix + encodeURIComponent(phrase) + suffixto
const phrase = 'à côté de' const prefix = 'https://www.linguee.fr/anglais-francais/search?query=' const url = prefix + encodeURIComponent(phrase)and
'%C3%A0%20cot%C3%A9%20de' to '%C3%A0%20c%C3%B4t%C3%A9%20de'\${\nu\upsilon{
including three backslashes. The second string has two characters:
}}
let hours = '10:30 - 12:00'.match(/[0-9]+(?=:)/g) // ['10, 12']to
let hours = '10:30 - 12:00'.match(/[0-9]+(?=:)/g) // ['10', '12']and
let minutes = '10:30 - 12:00'.match(/[0-9][0-9](?!:)/g) // ['10, 12']to
let minutes = '10:30 - 12:00'.match(/[0-9][0-9](?!:)/g) // ['30', '00']
// someNumbers.length is 4 to // someNames.length is 4pop(), shift(), change “Removes and returns the last element” to Removes and returns the last or first elementfirstIndex/lastIndex to indexOf/lastIndexOfmap.forEach((key, value) => { to map.forEach((value, key) => { const iarr = new Int32Array(1024)to
const iarr = new Int16Array(1024)and “Since
40000 is too large to fit in the range of 32-bit integers, the last 32 bits are taken” to “Since 40000 is too large to fit in the range of 16-bit integers, the last 16 bits are taken”const farr = Float32Array.of(1, 0.5, 0.25, 0.125, 0.0625, 0.03215, 0.015625)to
const farr = Float32Array.of(1, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625)
'31.12.1999 23:59:00'” to “// Yields the string '31.12.1999, 23:59:00'”123,456.78 to 123.456,78 (2x) and switch value: '.' and value: ','The Intl.Locale class provides a way for denoting a locale with certain options:
const usMilitaryTime = new Intl.Locale('en-US', { hourCycle: 'h23' })
Supported options are: language, script, region,
calendar, collation, hourCycle, caseFirst, numeric, numberingSystem.
finally method invokes a handler whether or not a promise has settled.” to “The finally method invokes a handler whether or not a promise has been fulfilled. ”for (url of urls) to for (const url of urls) (2x)Promise.all:
const [img1, img2] = [await loadImage(url), await loadCatImage()]
encrypt(key) and decrypt(key) to encrypt(str) and decrypt(str)Function” to “Every function that is defined with the function keyword”Symbol.iterable to Symbol.iterator for (line of lines(filename)) {
if (line.contains(target)) {
to
for (const line of lines(filename)) {
if (line.includes(target)) {
accum.throw() // Returns { value: 0, done; false }
to
accum.throw() // Returns { value: 0, done: false }
const more = (values: number[] | string[]) => {
if (array.length > 0 && typeof x[0] === 'number') // Error—not a valid type guard
return values.map(x => x + 1)
else
return values.map(x => x + x)
}
to
const more = (values: number[] | string[]) => {
if (values.length > 0 && typeof values[0] === 'number') // Error—not a valid type guard
return values.map(x => x + 1)
else
return values.map(x => x + x)
}
=> to the preceding line:
. . .: string }) =>
leftDelimiter + . . .
pf can surely accept” to “This assignment is sound because pc can surely accept”replace to replaceAll (11×)constructor(key: K, second: V) to constructor(key: K, value: V)let greeting = 'Hello'to
let greeting: String = 'Hello'
arr to more (2×)Thanks to Iskandar Agung, Sundararajan Athijegannathan, Jisu Chung, Massimiliano De Simone, Tessio Fechine, Dominik Gruntz, Katsutaka Ishibashi, Mark Meyer, Amiel Nava, Dumitru Postoronca, Jonas Rathert, Tekin Sal, Christiaan Smith, Koray Tugay, Eran Yarkon, Kunio Yoshikawa and (your name might go here) for their bug reports!
If you have found another bug in the book or in our code that is not mentioned in this bug list, then please send a report. Unfortunately, I cannot reply personally to each report, but I do read all your comments.