• <legend id='IvASe'><style id='IvASe'><dir id='IvASe'><q id='IvASe'></q></dir></style></legend>
    1. <i id='IvASe'><tr id='IvASe'><dt id='IvASe'><q id='IvASe'><span id='IvASe'><b id='IvASe'><form id='IvASe'><ins id='IvASe'></ins><ul id='IvASe'></ul><sub id='IvASe'></sub></form><legend id='IvASe'></legend><bdo id='IvASe'><pre id='IvASe'><center id='IvASe'></center></pre></bdo></b><th id='IvASe'></th></span></q></dt></tr></i><div id='IvASe'><tfoot id='IvASe'></tfoot><dl id='IvASe'><fieldset id='IvASe'></fieldset></dl></div>
      <tfoot id='IvASe'></tfoot>

        • <bdo id='IvASe'></bdo><ul id='IvASe'></ul>

        <small id='IvASe'></small><noframes id='IvASe'>

        使用 javascript 确定 javascript 中的堆栈深度

        determine stack depth in javascript using javascript(使用 javascript 确定 javascript 中的堆栈深度)

          <tbody id='IX2zx'></tbody>
        <tfoot id='IX2zx'></tfoot>

        <i id='IX2zx'><tr id='IX2zx'><dt id='IX2zx'><q id='IX2zx'><span id='IX2zx'><b id='IX2zx'><form id='IX2zx'><ins id='IX2zx'></ins><ul id='IX2zx'></ul><sub id='IX2zx'></sub></form><legend id='IX2zx'></legend><bdo id='IX2zx'><pre id='IX2zx'><center id='IX2zx'></center></pre></bdo></b><th id='IX2zx'></th></span></q></dt></tr></i><div id='IX2zx'><tfoot id='IX2zx'></tfoot><dl id='IX2zx'><fieldset id='IX2zx'></fieldset></dl></div>
        1. <legend id='IX2zx'><style id='IX2zx'><dir id='IX2zx'><q id='IX2zx'></q></dir></style></legend>

          • <small id='IX2zx'></small><noframes id='IX2zx'>

                <bdo id='IX2zx'></bdo><ul id='IX2zx'></ul>
                • 本文介绍了使用 javascript 确定 javascript 中的堆栈深度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法通过使用 javascript 本身来确定在 javascript 中执行的所有函数的堆栈深度?

                  Is there a way to determine the stack depth of all functions being executed in javascript by using javascript itself?

                  我在想这可能涉及修改 Function 原型,但我真的不知道.

                  I'm thinking it might involve modifying the Function prototype, but I really don't have any idea.

                  此外,能够在堆栈深度足够高的任何时候中断会很好.

                  Additionally, it would be nice to be able to break anytime the stack depth were sufficiently high.

                  原因是我有一个 IE 中的堆栈溢出错误,显然不可调试.我很懒惰,我宁愿不必通过我维护的代码来寻找原因.

                  The reason for this is that I have a stack overflow error in IE which is apparently not debuggable. I'm lazy and I would rather not have to hunt through the code that I'm maintaining to find the cause.

                  感谢您帮助我的懒惰.

                  推荐答案

                  ECMAscript 支持 Function.prototype.caller 属性已经有一段时间了.即使它在 ES5 strict 中被弃用,IE 仍然应该支持它.因此,您基本上可以通过所涉及的功能循环往上.

                  ECMAscript supported for quite a while the Function.prototype.caller property. Even if its deprecated in ES5 strict, IE should still support it. So you could basically loop your way up through the involved functions.

                  function one() {
                     two();
                  }
                  
                  function two() {
                     three();
                  }
                  
                  function three() {
                      var caller = three.caller;
                  
                      console.log('caller was: ', caller.name);
                  
                      while( caller = caller.caller ) {
                             console.log('caller was: ', caller.name);
                      }
                  }
                  
                  (function outer() {
                      one();
                  }());
                  

                  这将输出:

                  caller was: two
                  caller was: one
                  caller was: _outer
                  

                  因此,如果您知道错误发生在哪个函数中,那么您就可以从最初调用该方法的方式中得到答案.如果您只是在深度之后,您可以计算对 caller.caller 属性进行了多少次交互.至少 IE8 应该支持debugger"语句,您可以在该脚本中调用它来将调试器带到舞台上.

                  So, if you know in which function an error happens, that way you get the answer all the way up how this method was originally called. If you're just after the depth, you can just count how many interations over the caller.caller property were made. At least IE8 should support the "debugger" statement, which you could just call in that script to bring the debugger on the stage.

                  这篇关于使用 javascript 确定 javascript 中的堆栈深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                      <tbody id='Xtx0J'></tbody>

                      <small id='Xtx0J'></small><noframes id='Xtx0J'>

                    1. <i id='Xtx0J'><tr id='Xtx0J'><dt id='Xtx0J'><q id='Xtx0J'><span id='Xtx0J'><b id='Xtx0J'><form id='Xtx0J'><ins id='Xtx0J'></ins><ul id='Xtx0J'></ul><sub id='Xtx0J'></sub></form><legend id='Xtx0J'></legend><bdo id='Xtx0J'><pre id='Xtx0J'><center id='Xtx0J'></center></pre></bdo></b><th id='Xtx0J'></th></span></q></dt></tr></i><div id='Xtx0J'><tfoot id='Xtx0J'></tfoot><dl id='Xtx0J'><fieldset id='Xtx0J'></fieldset></dl></div>

                    2. <tfoot id='Xtx0J'></tfoot>
                      <legend id='Xtx0J'><style id='Xtx0J'><dir id='Xtx0J'><q id='Xtx0J'></q></dir></style></legend>

                        • <bdo id='Xtx0J'></bdo><ul id='Xtx0J'></ul>