You do not have to pass it, but the function needs to be handled in case the parameter is not set, otherwise it will not make sense to do so.
For example, we assume a function that displays a greeting message on the console. The function will receive the name to which it will be greeted:
function hello(name) {
console.log('Olá, ${name}')
}
<button onclick="hello('mandioca')">Saudar</button>
But, look what happens when you do not set the parameter:
function hello(name) {
console.log('Olá, ${name}')
}
<button onclick="hello()">Saudar</button>
The function is executed, but an "undefined" appears because the parameter has not been defined.
In this case, if it really makes sense to call the function like this, you can assign a default value when the parameter is not set:
function hello(name) {
name = name || 'mandioca' // Se não tiver definido, atribui o valor 'mandioca'
console.log('Olá, ${name}')
}
<button onclick="hello()">Saudar</button>
So when you call the function without a parameter, the function will assign a default value and continue execution.