If you're coming from Python, you might be thinking:
Ah, so
undefinedis likeNone! Easy peasy.
Yes. But also... no. One of JavaScript's most cursed features is that it has two values for "nothing":
undefined: It doesn't exist at all. In grug-speak undefined is "very nothing"null: It (kind of) exists, but it's empty. In grug-speak null is "kinda nothing"There are some practical differences between the two, the primary one being that undefined is the default value of a variable when it hasn't been given a value yet.
let myName;
console.log(myName); // undefined
To get a null value, you have to explicitly assign it:
let myName = null;
console.log(myName); // null
Confusingly, typeof returns "object" for null:
console.log(typeof null); // object
To be clear, null is its own type according to the ECMAScript specification, but the "object" type report is a historical quirk that can't be easily fixed now.
In most cases, null and undefined work the same way, but you'll want to be consistent in how you use them, and know that there are subtle behavioral differences.
I personally use undefined almost everywhere I would use None in Python or nil in Go. JavaScript is fairly unique in having two options. I only use null in cases where the behavioral difference matters, or I'm relying on external code that forces me to use null.
Textio has lots of legacy code that checks if specific values are null. Just to be safe, the engineering team decided on a standard where variables that aren't declared with a specific value should be set to null instead of the default undefined. Fix the code so that each variable holds a null value.