I have a code like:
$(function () {
var addUserUrl = 'some string from the app';
$('.select2').on('change', function() {
console.log( addUserUrl );
// Next line is the problem because of redefinition of var
var addUserUrl = addUserUrl.replace(/idHolder/, $(this).val();
});
});
and as I see addUserUrl in onChange callback is undefined. I am little confused. The scope of lambda function is the same as scope of addUserUrl in my opinion. Can somebody explain me please what happens there?