Closed tdd closed 7 years ago
For the second problem, already reported and fixed: https://github.com/nzakas/understandinges6/issues/349
For the first issue - I suspect I changed around this example several times while writing and that the substring
call is a vestigial artifact from that. I'll clean it up.
Hi Nicholas,
Location: Chapter 6 > Page 110 > "The …Symbol.replace… properties" > code example
There are two things that puzzle me here, so perhaps I failed to grok something.
First, your
Symbol.replace
implementation has the following code:Aside from my personal preference for
slice
oversubstring
:wink, I fail to see the use of doing asubstring(10)
over a value guaranteed to be 10 code units long. You'll always get an empty string. So what's the point? Guaranteeing aString
due to implicit+
coercion semantics? (in which case, justString(replacement)
would be nicer). I'm at a loss here.Second, your demo calling code only provides a single argument to
replace
, so there should be no result, or undefined, in thereplace1
variable. But more generally, such calls don't make much sense usage-wise?