In the last abstraction example (when you took the abstraction too far) the logic in the code is wrong compared with the original example shown earlier. So if this is intentionally, please disregard the comment below and just add clarification in the description of the example.
The code above is ok to check if a property of an object is undefined, but here you change the logic of the previous example and check if a property of the store is undefined.
You return isUndefined result which is true if the property is undefined, so the logic is wrong once again.
Proposal:
Just change the name of the function and wrap the function in another one which accepts the property to be checked against undefined. This will lead to the need of invoking the function with an argument name in this case.
The code above is ok to check if a property of an object is undefined, but here you change the logic of the previous example and check if a property of the store is undefined.
"property of an object" vs "property of the store"... these are the same thing, I'm not sure what distinction you're trying to make?
You return isUndefined
You're correct, I accidentally reversed the logic here. Not that it really matters all that much, since this whole section of code is what not to do. But it's something that could be cleaner. The simple fix would just be:
"property of an object" vs "property of the store"... these are the same thing, I'm not sure what distinction you're trying to make?
You are right. The thing is that in the original example you check if the name of the event is undefined, but in the last example you check if the key in the store is undefined, so this is the wrong logic I'm trying to fix.
No thanks. I won't be making changes to the book since it's been in print for almost 2 years now. These changes will be addressed when/if I release a second edition.
Activity
getify commented on Oct 5, 2019
"property of an object" vs "property of the store"... these are the same thing, I'm not sure what distinction you're trying to make?
You're correct, I accidentally reversed the logic here. Not that it really matters all that much, since this whole section of code is what not to do. But it's something that could be cleaner. The simple fix would just be:
It's something I'll take a look at for next revisions/editions of the book.
vesheff commented on Oct 6, 2019
You are right. The thing is that in the original example you check if the name of the event is undefined, but in the last example you check if the key in the store is undefined, so this is the wrong logic I'm trying to fix.
getify commented on Oct 6, 2019
Oh, I see. OK, yes, I'll fix that too.
vesheff commented on Oct 6, 2019
If you want I could make a pull request on that.
getify commented on Oct 6, 2019
No thanks. I won't be making changes to the book since it's been in print for almost 2 years now. These changes will be addressed when/if I release a second edition.