A pop-up used to mean a library and some CSS tricks for the dark overlay. The browser can do it with an element that has been around for a while.
showModal() shows the dialog as a modal in the top layer, so it sits above everything else with a ::backdrop behind it that you can style. Pressing Escape closes it by default.
A form with method="dialog" closes the dialog when submitted, and the value of the button you pressed ends up in dialog.returnValue. A close event fires afterwards, so you can react to the answer.
d.addEventListener('close', () => console.log(d.returnValue));
A call to close() closes it from script, and it cannot be cancelled. If you want a cancellable close, MDN lists requestClose().
The caveat is the other opening method: show() opens it without the modal behaviour, and calling showModal() on a dialog that is already open that way throws an InvalidStateError. Keep to one method per dialog, and give the dialog a clear heading or label so people using a screen reader know what it asks. Focus handling for a modal dialog is done by the browser, which is the biggest reason I would pick this over a hand-made overlay.
Further reading: MDN: dialog element, MDN: HTMLDialogElement.showModal()