Open
Description
Hi and thank you for this really helpful book.
I think I might have spotted a very minor mistake in the OOP section?
Under "classes" there's the following snippet:
https://github.com/software-tools-in-javascript/js4ds/blob/a15c852e4b2df6d19380ee80075eb8cc5aeb6421/oop.tex#L211
for (let thing of everything) {
const a = thing.area(thing)
const p = thing.perimeter(thing)
console.log(`${thing.name}: area ${a} perimeter ${p}`)
}
Notice the snippet shows passing the instance into itself (const a = thing.area(thing)
).
But this is right after the text has gone to great lengths to explain that
Building every object by hand and calling
thing.function(thing)
is clumsy
and why you don't need to do that with classes.
I tested the snippet without passing thing
into the method calls
for (let thing of everything) {
const a = thing.area()
const p = thing.perimeter()
console.log(`${thing.name}: area ${a} perimeter ${p}`)
}
and it worked as expected.
Should those extra thing
s be removed?
Metadata
Metadata
Assignees
Labels
No labels