• Home
  • using underscore to verify if a variable is undefined or null

using underscore to verify if a variable is undefined or null

April 21, 2016 Ning 1 Comment

Example of if a variable is undefined

function test() {
    console.log(_.isUndefined(foo)); // true, no error due to hoisting
    var foo = 3;
    console.log(_.isUndefined(foo)); // false, foo is defined now.
}

Example of if a variable is null

function test() {
var foo = null;
console.log(_.isNull(foo)); // true,
var foo = 3;
console.log(_.isNull(foo)); // false,
}

One Comment

    August 12, 2016 REPLY

    Yo27#8u1&;re absolutely right on. 1) Take the time to figrue out your why otherwise you will struggle. 2) Staying motivated all the time is crucial to building and maintaining momentum. 3) With so much noise out there it can be tough to stay focused, but stay focused you must. 4) Connecting with successful MLMers is what will help you maintain #2 & #3. Great article!

leave a comment

*