I would like to report errors In Chapter 6 “Symbols and Symbols properties” (Ido not have page#, because I bought it as e-book)”.
In example on Symbol.replace overriding:
hasLengthOf10 = {
...,
[Symbol.replace]: function( value, replacement) { return value.length = = = 10 ? replacement + value.substring( 10) : value; },
...
}
value.substring(10) expression in this context always evaluates to “undefined” and should not be there.
Also following
console.log( replace2); // "Hello John"
is incorrect and should be
console.log( replace2); // “undefined”