I’m using node.js’s util.inspect call to dump a JavaScript associative array to the log. The associative array in question includes member properties that are functions. An example is:
var pendingscreen = {};
pendingscreen['timeoutfunction'] = function(){ sendmsg(); };
pendingscreen['timeout'] = setTimeout(pendingscreen['timeoutfunction'], 1000);
console.log(util.inspect(pendingscreen));
When I run this, I get this error:
TypeError: Function.prototype.toString is not generic
at Client.toString (native)
at String.STRING_ADD_LEFT (native)
at isRegExp (util.js:287:14)
at format (util.js:184:11)
at util.js:216:19
at Array.map (native)
at format (util.js:193:23)
at util.js:216:19
at Array.map (native)
at format (util.js:193:23)
Is there any way to inspect the members of an associative array where some of the members could be functions?
util.inspectshould handle this just fine. However there is a bug in the node.js version you are using which can cause this error.This is fixed in newer version (>=0.4.11).