Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var isset = function(myVarString){
- var arr = myVarString.split("."); //get properties - only works with "<property>.<property>" notation.
- var last = "this.";
- for(var i = 0; i < arr.length; i++){
- if(typeof eval(last + arr[i]) !== "undefined"){
- last = last + arr[i] + ".";
- } else {
- return false;
- }
- }
- return true;
- };
- /*
- * - Usage
- *
- *
- if(isset('objectName.childProperty.grandchildProperty')){
- //do stuff
- }
- */
Add Comment
Please, Sign In to add comment