Implies that there is no element with the ID “button”.
Note that an id is an attribute, not an element type. <button> can be found by getElementsByTagName, but to find something with id button, it would have to be <something id="button">
To take it one step further you could add an id to the button
const body = document.body;
const textArea = document.createElement('textarea');
const button = document.createElement('button');
button.textContent = 'Click Me';
button.id = 'button-1' // add an id to it
body.append(textArea);
body.append(button)
// often referred to as a 'handler'
function clickHandler() {
console.log('abc');
}
button.addEventListener('click', clickHandler);
// get newly created button from the DOM
console.log(document.getElementById('button-1'))
// <button id="button-1">Click Me</button>