In the example below, we create a button and attach a click event to it.
const button = document.createElement('button');
button.innerHTML = 'Click';
document.body.appendChild(button);
const test = (val) => {
console.log('clicked ' + val);
};
button.addEventListener('click', test.bind(this, 'test'));