Is there any way to create a function with a real name that's determined at runtime without using eval
, and using only pure JavaScript? (So, no generated script
elements, as those are specific to the browser environment [and in many ways would be eval
in disguise anyway]; no using non-standard features of one particular JavaScript engine, etc.)
Note that I'm specifically not asking about anonymous functions referenced by variables or properties that have names, e.g.:
// NOT this
var name = /* ...come up with the name... */;
var obj = {};
obj[name] = function() { /* ... */ };
There, while the object property has a name, the function does not. Anonymous functions are fine for lots of things, but not what I'm looking for here. I want the function to have a name (e.g., to show up in call stacks in debuggers, etc.).