
Tech
The One-Line Refactor That Made this Become undefined in Production
Unlike languages where this is lexically bound to a class instance at definition time, JavaScript decides what this refers to at the moment a function is called, not where it was written. That single distinction has caused more runtime errors than any other keyword in the language.
The refactor looked completely safe. A method called updateUser lived on a userStore object, and a component needed to call it in response to a button click. Someone extracted the reference to make the cod...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to