Putting equal sign between the method and the function - JavaScript

Hello, I bumped into problem using a Speech Synthesis API. I want to get all of the voices that are installed on computer so I used the Speech Synthesis method .getVoices(). However when I tried to log the response into console it showed an empty array. I found on internet that the .getVoices() function is runned asynchronously so this is causing this problem. You can solve this problem using .onvoiceschanged object that is assigned to Speech Synthesis API and is fired everytime the voice list is changed. I found this code on internet that solves the problem:

const synth = window.speechSynthesis;
let voices = [];

const getVoices = () => {
  voices = synth.getVoices();
  console.log(voices);
}

getVoices();
if (synth.onvoiceschanged !== undefined) {
  synth.onvoiceschanged = getVoices;

But I don’t understand it. What I see in this is code is:

  1. Go into if loop if the voice list has been updated
  2. But then I don’t understand this syntax (synth.onvoiceschanged = getVoices;), when we are putting equal sign between the method and function. What do we achieve by doing something like this?

You’re assigning the function getVoices to the property onvoiceschanged on the synth object.

synth = {
  onvoiceschanged: // some function
}

synth.invoiceschanged = getVoices

// Now `synth` looks like
// {
//  onvoiceschanged: getVoices
// }