> var a = Promise.resolve
undefined
> a(1)
TypeError: a is not a function
at resolve (native)
at repl:1:1
at REPLServer.defaultEval (repl.js:248:27)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:412:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
回复 (1)
D
没特别,只是这样调用并不是以对象的方法的方式调用,上下文丢了。 这样:
> var a = Promise.resolve
undefined
> a.call(Promise, 2)
Promise { 2 }
参与回复
登录后即可参与回复。登录