이 내 클라이언트 JS 스크립트이것을 피하는 방법 socket.io를 사용하는 JS에서?
var Chat = function(username) {
that = this;
this.myUser = {"username":username};
this.socket = io(server);
this.socket.on('connect', function(){
console.log(that.myUser); // this is UGLY but this.myUser will give an error
});
}
"이 = 그"그 불쾌한 제거하는 방법에 대한 어떤 생각인가?
'self = this' ... (농담) –