我试图从 调用该方法clean
,getUser
但它返回undefined
。如果我打电话u.test()
,它会完美运行。
我该如何解决这个问题?
class User
constructor: () ->
@db = # connect to db...
clean: (user, callback) ->
delete user.password
callback user
getUser: (id) ->
@db.get id, (err, user) ->
@clean user, (u) -> console.log u
test: () ->
@clean {name: "test", password: "hello"}, (u) ->
console.log u
u = new User
u.getUser()