peimin224
V2EX  ›  问与答

node.js 函数调用问题

  •  
  •   peimin224 · Jan 13, 2020 · 1720 views
    This topic created in 2323 days ago, the information mentioned may be changed or developed.

    我在调试 node.js 的时候,debugger 的时候出现函数未定义,code 如下所示:

    function a() { return c() } function c() { return 2 } function b() { debugger; // 这里会提示 c 未定义 return a() } b();

    报错如下: ReferenceError: c is not defined

    但是我在 Chrome 浏览器中调试就没有任何问题。 我想问一下在 node.js 中这种情况应该怎么处理成与浏览器中的效果一样。

    1 replies    2020-01-14 13:53:39 +08:00
    jifengg
        1
    jifengg  
       Jan 14, 2020
    function a() { return c() } function c() { console.log(2) } function b() { return a() } b();

    nodejs 中运行没问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1076 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:05 · PVG 02:05 · LAX 11:05 · JFK 14:05
    ♥ Do have faith in what you're doing.