How to get Content ID in a View (.hbs file), or how does getContext() returns it?

Thank you for the tip, I did it like this now:

(async function() {
    var context = await AP.context.getContext();
    return context.confluence.content.id;
})().then(function(pageID) {
    console.log("pageID", pageID);
});

I can work in the unnamed function in the .then() part now, but maybe it’s a stupid question, but is there a possibility to get the result (the pageID) out of the scope of that unnamed function?
I see… I need to read about async JavaScript…