Prevent duplicate JavaScript event handlers in Drupal 8

Drupal behaviors documentation suggests that we use the "once" method to prevent binding JavaScript event handlers multiple times on Ajax requests.

Prevent multiple binding of JavaScript event handlers

If you use event listener functions in Drupal behaviors, use .once() function to avoid duplicate handlers after running Ajax requests.

In this example, clicking on a button element toggles a paragraph, and it will work well if you don't run any Ajax requests on the same page. But if you do, Drupal.behaviors will run again on the button and click listener will be added multiple times. Consequently the paragraph will be toggled multiple times.