How can I access variables outside of current scope in javascript?

后端 未结 3 949
小蘑菇
小蘑菇 2020-12-17 02:02

I\'m writing an application in javascript and cannot figure it out how to access the variables declared in my function, inside this jquery parse. Inside I can access global

3条回答
  •  爱一瞬间的悲伤
    2020-12-17 02:36

    The simplest change you can do to make it work is... Change your function in each from normal ( function() {}) to arrow function ( () => {} ) that will automatically take the context of the function in which it is defined.

提交回复
热议问题