Advertisement
Peaser

call func if valid and exists

May 9th, 2015
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Call function IF AND ONLY IF IT EXISTS AND IS VALID otherwise return as undefined */
  2. function chcalc(name) {chcalc:{
  3.   try {
  4.     eval(name)
  5.   } catch(err) {
  6.     break chcalc
  7.   }
  8.   if (typeof eval(name) == 'function') {
  9.   eval(name)();
  10.   }
  11. }}
  12.  
  13. // Minified Version:
  14. /*
  15.  
  16. function chcalc(name){a:{try{eval(name)}catch(err){break a}"function"==typeof eval(name)&&eval(name)()}}
  17.  
  18. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement