If a promise object is set inside a function , will the promise object get removed from memory once the function is completed?

I was wondering if I use fetch method to return a promise object to handle asynchronous operation inside a function looks like this:

<script>
    function test(){
        promise = fetch("https://xxx");
        promise.then(()=>{console.log("completed!")});
    };
    test()
</script>

This will work but my question is once the function test() is executed completely, according to the basic in Javascript where “Function (local) variables are deleted when the function is completed.” , my thought is that the promise variable will get deleted and the actual promise object sits somewhere in the memory would have 0 reference, so it would get deleted by javascript. But it still work

Is it the implementation of Promise object sets it work differently in Javascript?

Thank you so much!!