Anonymous functions allow us to compartmentalise our code and avoid [polluting the global scope][global scope]. The difference between using and not using an anonymous function is explained with a basic example of changing the background color to red when the DOM is ready.
Here we use the onload
method of document.body
.