is there something like isset of php in javascript/jQuery?

Try this expression:

typeof(variable) != "undefined" && variable !== null

This will be true if the variable is defined and not null, which is the equivalent of how PHP’s isset works.

You can use it like this:

if(typeof(variable) != "undefined" && variable !== null) {
    bla();
}

Leave a Comment