1

How can I access test inside the fadeOut() callback?

  slide(test) {
    console.log("test before callback: ", test);
    $(".class").fadeOut(1000, function(test) {
      console.log("test after callback: ", test);
    });
  }

slide()

test before callback:  Proxy {dispatchConfig: {…}, _targetInst: ReactDOMComponent, isDefaultPrevented: ƒ, isPropagationStopped: ƒ, _dispatchListeners: ƒ, …}
45my.js:17 test after callback:  undefined
smilebomb
  • 4,641
  • 8
  • 41
  • 76

1 Answers1

0

Remove test from the callback parameter as that is shadowing your outer most test argument.

View this question for a bit about shadowing in JavaScript An example of variable shadowing in javascript

john-raymon
  • 158
  • 4
  • 19