Tuesday, May 14, 2013

Javascript: Get all function of an object

 
function getMethods(obj) {
 var result = [];
 for (var id in obj) {
  try {
   if (typeof(obj[id]) == "function") {
    result.push(id + ": " + obj[id].toString());
    //result.push(id);
   }
  } catch (err) {
   result.push(id + ": inaccessible");
  }
 }
 return result;
}

No comments: