4 ms·
What's the goal there? v8, at least, will give the name in a stack trace even if the function is declared like `var a = function(){}`.
by thedufer 13y ago
What's the goal there? v8, at least, will give the name in a stack trace even if the function is declared like `var a = function(){}`.
- Cthulhu_ 13y agoReally? I'm using Chrome, and at least for me, unfortunately it doesn't. Second, V8 isn't the only JS engine out there, a lot of tools will simply put the function as 'anonymous function' in stack traces.
- thedufer 13y ago> var a = function(){throw Error('err')} undefined > try{a()}catch(err){err.stack} "Error: err at Error (native) at a (<anonymous>:2:26) at <anonymous>:2:5 at Object.InjectedScript._evaluateOn (<anonymous>:641:39) at Object.InjectedScript._evaluateAndWrap (<anonymous>:580:52) at Object.InjectedScript.evaluate (<anonymous>:495:21)" The "at a" is what we're looking for. I develop largely in Chrome; its been doing this for months, at least. It also works in IE11 (the only version I have readily available), Firefox, and Safari.