search

Home  >  Q&A  >  body text

node.js - node 回调函数中 var temp = this 的意义

PHPzPHPz2875 days ago591

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 16:04:27

    See notes:

    this is req, which is a streamthis is req, which is a stream

    此时this指向req,而req对外可以当做是stream

    At this time, this points to req, and req can be used as stream externally, just changing the name , it seems clearer, it has no special meaning. 🎜

    reply
    0
  • 迷茫

    迷茫2017-04-17 16:04:27

    I can only say that this demo is poorly written, and there is no need to be superstitious and overly speculate on its intentions.


    Normal similar writing is like this

    var xx = function() {
        var that = this;
        
        return funtion() {
            that.xxx
        }
    }

    You can reference this in the upper scope in the closure

    reply
    0
  • Cancelreply