A simple rule that I introduced in the previous company where I worked:
Always initialize variables with null, any encountered undefined was treated as an error.
Typically, we'd only have undefined values when working with externally provided data, and we'd have validation logic on incoming data anyway, which took care of transforming it into null (or throwing an error, depending on which was appropriate).
Simply put, a null is intentionally empty, an undefined indicated that something wasn't 100% right.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A simple rule that I introduced in the previous company where I worked:
Always initialize variables with
null, any encounteredundefinedwas treated as an error.Typically, we'd only have
undefinedvalues when working with externally provided data, and we'd have validation logic on incoming data anyway, which took care of transforming it intonull(or throwing an error, depending on which was appropriate).Simply put, a
nullis intentionally empty, anundefinedindicated that something wasn't 100% right.