Utilizing Lodash's isUndefined
and isNull
methods can be quite handy. For instance, if you have a number variable that needs to be checked for existence before using it, you could approach it like this:
someNumber:number;
......
if (_.isUndefined(someNumber) || _.isNull(someNumber)) {
console.log('not set');
}
While the above method works fine, I'm curious if there are any distinctions between the initial technique and an alternative approach like this:
if (!someNumber) {
console.log('not set');
}