4
我試圖從getUser
調用方法clean
,但它返回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()