When menu button (or any other object which class you will add) is clicked, the JS code will change the CSS of the body and make it overflow: hidden >>> that makes the body unscrollable.
Then, the next part of the script takes the click from another element (close button, menu, modal background, etc.) and change the CSS of the body again, making it overflow: auto >>> that makes the body scrolling again.
Definitely a great question, and hopefully this is helpful.
Got to see a huge thank you to @sabanna for the original walk-through