Sharepoint - Query multiple lists using javascript/CSOM

The OOP suggestion solves your context problem but it is kinda like saying:

We have a flat tire, lets change cars!

Your issue is with the this context you give to your processing function, so lets fix that tire.

Instead of passing it the whole truck you only want to pass the payload:

with: processItems.bind(request)

function getItems(listName,siteUrl){
    var request={};
    request.listName=listName;
    request.siteUrl=siteUrl || _spPageContextInfo.siteAbsoluteUrl;
    var ctx = new SP.ClientContext(request.siteUrl);
    var list = ctx.get_web().get_lists().getByTitle(request.listName);
    request.query=SP.CamlQuery.createAllItemsQuery();
    request.itemCollection=list.getItems(request.query);
    ctx.load(request.itemCollection);
    ctx.executeQueryAsync(  processItems.bind(request)  ,failure);
}
function processItems() {
    var received=this;//received 'request' from Caller
    received.items=[];
    var listEnumerator = received.itemCollection.getEnumerator();
    while (listEnumerator.moveNext()) {
        var listitem = listEnumerator.get_current();
        received.items.push(listitem.get_id());
    }
    console.info(received.listName,'has',received.items.length,'items IDs:',received.items);
}
function failure(sender, args){
    console.error(args.get_message());
}
console.clear();
for(var cycle=1;cycle<4;cycle++){// call multiple times to show ASYNC result in the console
    console.log('Calling 3 lists cycle:',cycle);
    getItems('Tasks');
    getItems('Documents');
    getItems('Images');
}

You could have bound just the itemCollection itself, but I elaborated a bit to show how to pass more data.

For (oldschool) CreateDelegate and (since ES-5) bind() differences see: Differing ways to make executeQueryAsync calls - Function.createDelegate (is old IE8 code)

Run this and you will see the asynchronous responses:
(Tasks was requested first, but Documents was received first, etc)

J1 J5 iJSOM TOP5