How to pass variable to the function?

How to pass the AAA function BBB?

var AAA="555";
document.addEventListener('touchmove', BBB(AAA));
function BBB(AAA) {
AAA = AAA + 5;
return AAA;
}

PS. Write the function of determining whether scrolling up or down, on mobile.
March 23rd 20 at 19:08
3 answers
March 23rd 20 at 19:10
Solution
document.addEventListener('touchmove', BBB.bind(this, AAA));
// or
document.addEventListener('touchmove', function () {
BBB(AAA);
});
March 23rd 20 at 19:12
Solution
var AAA="555";
document.addEventListener('touchmove', function () {
BBB(AAA);
});
function BBB(AAA) {
 AAA = AAA + 5;
 return AAA;
}

ps: please, call functions, and variables like human beings.
this is just an example, of course call a few words, and comment - Jean.Litt commented on March 23rd 20 at 19:15
March 23rd 20 at 19:14
var variable;
function functionname(variable) {
telophone;
}
it doesn't work.

var variable = 1;
function functionname(variable) {
 // telophone;
console.log(variable)
}

function_name(42); // -> 42
functionname() // -> undefined

console.log(variable) // and here still 1
- Nya_Hin commented on March 23rd 20 at 19:17
@Nya_Hin, I wrote the way that people for a couple grams better understand what was happening. And such nerds some do not understand - araceli_Run commented on March 23rd 20 at 19:20
@araceli_Run, for a couple of grams make it wrong? Great move. - Nya_Hin commented on March 23rd 20 at 19:23

Find more questions by tags JavaScript