Skip to main content

Posts

Showing posts from August, 2020

How to check for null and undefined variables? (JavaScript)

Using a hardcoded if...else operator like this will do the trick: if (variable === null || variable === undefined) {    // do something else } But seeing the code above makes me wonder if there are any concise way to do this. Then, I stumbled upon a stackoverflow answer that answers the question in a very concise manner: https://stackoverflow.com/questions/2647867/how-can-i-determine-if-a-variable-is-undefined-or-null