performance - What's the consensus on using Function.caller in JavaScript? -


a while ago read shouldn't use function.caller inside function because makes function non-inlineable. test assertion wrote following benchmark:

does function.caller affect preformance? · jsperf.

the results prove using function.caller indeed makes function execute slower normal:

  1. in opera 16% slower.
  2. in chrome 80% slower.
  3. in firefox 100% slower.

hence question this: what's concensus on using function.caller in javascript? alright use sparingly? should shunned altogether?

as far know, dynamically inspecting execution stack caller/callee/etc not allowed in strict mode can kind of see consensus avoid feature if possible.

anyway, why want use function.caller in first place? makes code depend on doesnt matter (the call stack) , data gets passed around implicitly instead of via explicit arguments. real use ever saw kind of feature printing stack traces , in case can pay performance cost or can around debugger.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -