I am learning javascript
Why the function.call() behaves differently with this
and without this
.
The program with this
in test.call()
and result is same when this
is replaced by undefined
function test(a,b){
console.log(a+b);
}
let args = [1,2]
test.call(this,...args);
// Output: 3
The program without this
in test.call()
function test(a,b){
console.log(a+b);
}
let args = [1,2]
test.call(...args);
// Output: NaN