Function behavior in JS : There is such a piece of JS code...

    <script>
        function test1() { console.log('Test 1'); }
        function test2() { console.log('Test 2'); }
        const button = document.getElementById('button');  
        button.onclick = function() { test1(); }
        button.onclick = function() { test2(); }
    </script>

...and a little ntml

    <button id="button">RGB</button>

When you click on a button, only "Test 2" is displayed in the console.

I would like to hear only an explanation of this behavior.
Еhank