Member-only story
Turn JavaScript Objects in Maps for Predictability
No more errors with undefined properties

The Problem With Objects
You’re deep into your code, and suddenly you get an error: “Cannot read property x of undefined.” Awww, man.
Most of the time, this means debugging — attacking my code with debugger
here, console.log()
there. Most of the time, I get it fixed fast. But there are those days that it takes me hours.
Example Problem
We have an object called car
.
The car object has a set of key-value pairs. We get this information from our API. Normally, you’d get an events
property inside the object that includes the property last_updated
— stating the last time this information has been changed.