-1

My code:

let currentResult = 0

const sum = (a, b) => {
    console.log(this) // line a
    return a + b
}

function subtract(a, b) {
    console.log(this) // line b
    return a - b;
}

console.log(this) // line c
currentResult = sum(4, 5)
currentResult = subtract(4, 5)
console.log(currentResult)

Why the output of line a and line c gives a curly bracket, line b gives a global object instead? I suppose all of them gives the global object.

Mcflurry
  • 5
  • 1
  • 2

0 Answers0