Discuss / JavaScript / 我不懂这个this的意思,指向的是什么呢?

我不懂这个this的意思,指向的是什么呢?

Topic source

function onConnect() { let user = this.user; // 为什么不是undefined let msg = createMessage('join', user, ${user.name} joined.); this.wss.broadcast(msg); // build user list: let users = this.wss.clients.map(function (client) { return client.user; }); this.send(createMessage('list', user, users)); }


  • 1

Reply