Here is functional code:
let fn = function() { console.log(arguments) }
let fn2 = function() { fn.apply(null, arguments) }
So after call fn2(1,'t',4)
getting Arguments { 0: 1, 1: "t", 2: 4, … }
.
But this code:
let def = { }
let p = new Promise((s,f)=>{
def.s = function() { s.apply(null, arguments) }
def.f = function() { f.apply(null, arguments) }
})
p.then(function(){
console.log(arguments)
})
Returning after call def.s(1,'T',2)
this Arguments { 0: 1, … }
.
Tried in Chrome and Firefox. Am I missing something? Thanks
A promise can resolve only with a single value, and then
callbacks are called with exactly one argument. Passing multiple things into resolve
or reject
is pointless. If you need all of them, pass them as a tuple value, as elements of an array.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.