Distinguish between Node’s native functions and anonymous functions


I’m looking for a way to traverse through an object and perform an action if I have an anonymous function and not perform the action if I have a native function.

This is best explained with an example:

User = {
first : String,
last : String,
email : function(email) {
// ....

User.forEach(function(prop) {
if(! native ) {
// Do something

Gut reaction is of course not, but console.log will output [Function: String] for the String native function, and [Function] for anonymous functions.

Thanks! Matt

Problem courtesy of: Matt


You can use toString() to look at the text of the function then look for functions without names:


Solution courtesy of: generalhenry

View additional discussion.