How to prevent the js listener from automatically declaring variables each time?

map.addEventListener("click", function(e){
    var onclick=0;
    if(onclick%2==0){
        onclickPP;
        var myP1 = new BMap.Point(e.point.lng,e.point.lat); 
        alert("onclick="+onclick);
        alert("" + e.point.lng + ", " + e.point.lat);
    }
    else{
        onclickPP;
        var myP2 = new BMap.Point(e.point.lng,e.point.lat); 
        alert("" + e.point.lng + ", " + e.point.lat);
        driving2.search(myP1, myP2);    //
        alert("onclick="+onclick);
        alert((map.getDistance(myP1, myP2)).toFixed(2)+" "); 
        }
    });
Does

redeclare onclick=0 every time the listener calls? But I write the declaration outside the listener and print the value of onclick for null,. What can I do to prevent me from declaring onclick? every time the listener is called?

Mar.10,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a6cb-2c1f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a6cb-2c1f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?