Reputation: 253
Does anyone know the args[3]
mean in this example?
createTransaction.mockImplementation((...args) => {
const setResult = args[3]
setResult({ ...result, approved: false })
})
Upvotes: 0
Views: 131
Reputation: 102277
...args
is called Rest parameters.
while rest parameters are
Array
instances, meaning methods likesort
,map
,forEach
orpop
can be applied on it directly
Array index can be used as well.
const mockImplementation = (...args) => console.log(args[3]);
mockImplementation(1,2,3,4) // 4
It will print the fourth element in the args
array instance.
Upvotes: 1