0
const foo = x => {
var y = x * 2

return function bar(z) {
  if (z.length > 3) {
    return z.map(
      (baz = v => {
        if (v > 3) return v + y
        else return baz(v * 4)
      })
    )
  } else {
    var obj = []
    const bam = () => {
      obj.length = 1
      obj[0] = this.w
    }
    setTimeout(bam.bind(this), 100)

    return obj
  }
}

I wanna convert "bar" function to arrow function, so what should i do with the 2 "this" inside?

Shina
  • 9
  • 1
  • 3
    *I wanna convert "bar" function to arrow function* — Stop wanting that. Use the right tool for the job. – Quentin Jun 01 '22 at 13:25
  • This is only possible if you change every place where `bar` is used to provide a appropriate value for `this`, since arrow functions can't get `this` from their environment – mousetail Jun 01 '22 at 13:27
  • @Quentin this is assignment that i have to replace all declaration/expression function by arrow function. So confused! – Shina Jun 01 '22 at 13:53

0 Answers0