How to create buttons in JavaScript?

To make a button in JavaScript, create a button element with document.createElement function.

Here's how you do it:

const button = document.createElement('button');

button.textContent = 'Click Me!';

button.addEventListener('click', () => {
  alert('Hey, someone clicked me!');
});

document.body.appendChild(button);

This will create a button labeled Click Me!, that shows a popup when clicked.