how to tell if a javascript variable is a function

Use the typeof operator:

if (typeof model[property] == 'function') ...

Also, note that you should be sure that the properties you are iterating are part of this object, and not inherited as a public property on the prototype of some other object up the inheritance chain:

for (var property in model){
  if (!model.hasOwnProperty(property)) continue;
  ...
}

Leave a Comment