Guest User

Untitled

a guest
Feb 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. var isset = function(myVarString){
  2.  
  3. var arr = myVarString.split("."); //get properties - only works with "<property>.<property>" notation.
  4. var last = "this.";
  5. for(var i = 0; i < arr.length; i++){
  6. if(typeof eval(last + arr[i]) !== "undefined"){
  7. last = last + arr[i] + ".";
  8. } else {
  9. return false;
  10. }
  11. }
  12.  
  13. return true;
  14.  
  15. };
  16.  
  17. /*
  18. * - Usage
  19. *
  20. *
  21.  
  22. if(isset('objectName.childProperty.grandchildProperty')){
  23. //do stuff
  24. }
  25.  
  26. */
Add Comment
Please, Sign In to add comment