For example this is our piece of code:
function blabla(A,B) {
// Something
httpReq.onreadystatechange = function(A,B) {
if (httpReq.readyState == 4) {
// console.log(A,B) says 'undefined'
// How can I use the values of A and B here?
};
}
}
You just use them. You problem is shadowing. The inner function arguments are overwriting the outer function ones because they have the same name.
Normally, any local variables are available with no trickyness to any function declared in the same scope. Meaning you just use them, as long as you dont shadow them with new local variables of the same name.
This just works, so long as you use a unique variable name for the arguments to each function.