Created
November 21, 2016 16:48
-
-
Save daylik/0c1ee228764099b8513dbfa7a7522d2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use isUnd(var_ , true); = yes undefined; || isUnd(var_ , false); = no undefined; | |
window.isUnd = function(v_var, v_boo ){ | |
//v_boo = (v_boo === true) ? true : false; | |
var isUnd_regex = /(undefined|NULL|NaN)/i; | |
if( isUnd_regex.test(v_var) ){ | |
if(v_boo) {return true;} else {return false;} //if undefined | |
} | |
if(v_boo) {return false;} else {return true;} //not undefined | |
}; | |
//this test | |
/* | |
var vot1, vot2 = 'vot2'; | |
if( isUnd(vot1, true) ){ console.log('yes undefined'); } else { console.log('not undefined'); } | |
if( isUnd(vot1, false) ){ console.log('not undefined'); } else { console.log('yes undefined'); } | |
*/ | |
//getHashNum('#news-id-123') //output 123 | |
window.getHashNum = function(v_var){ | |
var get_Hash_Num = get_Hash_Num.match(/[\w\W]+(\d+)/i); | |
if( get_Hash_Num && get_Hash_Num.length > 1 ){ return get_Hash_Num[1]; } return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment