Sometimes, I come across a piece of javascript code like this:
function someFunc() {
    var that = this;
    // do something with that
}
Why do people do this when you can just use 'this'?
Sometimes, I come across a piece of javascript code like this:
function someFunc() {
    var that = this;
    // do something with that
}
Why do people do this when you can just use 'this'?
 
    
    Check this example:
function someFunc() {
  var that = this;
  $('.test').on('click', function() {
    //in this scope the this will be different and if you'd like to use the this of someFunc then you need to assign another variable
  })
}
