Skip to content

Instantly share code, notes, and snippets.

@daylik daylik/isset.js
Last active Apr 19, 2017

Embed
What would you like to do?
window.isset = function(v_var) {
if(typeof(v_var) == 'number'){ if(isNaN(v_var)){return false;}}
if(typeof(v_var) == 'undefined' || v_var === null){return false;}
return true;
};
// if( typeof(v_var) == 'undefined' )
// or
// if( v_var === [][[]] )
//Console TEST
console.log('TEST:');
var v_1 = 1;
if(isset(v_1)){
console.log('isset true');
}
var v_2 = '1';
if(isset(v_2)){
console.log('isset true');
}
var v_3 = 'abc-абв';
if(isset_test(v_3)){
console.log('isset true');
}
var v_4 = ['a', 'b'];
if(isset(v_4)){
console.log('isset true');
}
var v_5 = {'1':'a'};
if(isset(v_5)){
console.log('isset true');
}
var v_6; //=undefined;
if(!isset(v_6)){
console.log('isset false');
}
var v_7 = Math.sqrt(-1); //=NaN
if(!isset(v_7)){
console.log('isset false');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.