The only similarity between a program function and a mathematical function is their exhibited behavior. Something in, something out, in a pure function sense, anyway. Math functions are always pure. Program functions are often times anything but. Intuitive programmers work to bring the same level of pure functionality to their code so it is just as declarative as math. This is a learned process, and takes lots of work to get to this level of expectation.
Some big words, or strange diction, will come up throughout any discussion concerning JS, and programming in general. A lot needs to be learned and understood to become a player in the development world. Learn as much as you can from other learners along the way, not just teachers or courses. That’s what you’ll find in these forums… Other learners.
Watching other learners struggle helps keep us from getting in too deep, too quick. We can feel free to admit that we’re struggling just as they are and can join the club. That’s how peer groups and teams begin to gel. Read their questions and admit you have the same ones. Learn alongside with them.
This is a very loaded question since so many terms and concepts come up in one go. One can see how it would be overwhelming to any learner. Let’s try to make this brief…
Start with any web page on the modern internet. Look around that page. There are probably a dozen different segments that are seemingly independent of one another. That may be so except from one small detail… All their code base name references exist in the same place in memory, the global namespace.
When scripts are loaded from several sources, there is always the possibility that their variables could collide with something already present in our script. That would be a huge disaster, whether the names reference values or functions. Do we want plug-ins to be messing with our own script behaviors? Na-ah-ahhhah! Hence the need to protect them.
Now we know that ‘global’ means the very environment where everything is rooted. The global namespace is where we find the names of everything given a reference in this environment. Global sort of means, ‘for all things concerned’, and all objects in this scope are accessible from anywhere in our program.
Mutation means change, and in programming that usually means evolved through multiple iterations over the same data structure. When we change the value of an element in an array, add to or delete a value from the array, we mutate that array. It’s still an array, but the contents have been altered.
Obviously any change to anything could be called mutation. For our purposes, if it is not an array or object, it is a set event, rather than a mutation. We are changing a state. Mutation means a data structure has changed.
If we’re getting anything of a grasp on this subject it’s clear we’re dealing with memory and memory management, although in JS we don’t have a direct hand in it. We manage memory by how we scope our variables. Functions offer us a means to request and release memory resources. It is when we fail to manage well that things get left in unreleased memory. This is the definition of leakage. It is lost memory. Excessive leakage can slow down a page, both in loading and in interaction.
As for polluting, that points directly to memory leakage, leaving detritus in the global namespace which pollutes that environment.