When writing a function the use of the return keyword is required if you want the function to return some kind of product. There is a few exceptions to this though when it comes to working with variables down the scope chain, and constructor functions, more on that later.
A function can be passed one or more arguments, or in other worlds independent variables, these argument values are then local to the body of the function when it comes to scope, and they are typically used in the process of creating and returning a value of some kind. However they differ from any additional variables that may be defined inside or outside of the body of the function.
Functions do not always have to be used to return something though, often a function is just used as a way to keep things encapsulated from everything else. However getting back to the topic at hand here, it is import to know that arguments can of course be added to functions by simply just having a few argument names for them. There is a lot more to write about when it comes to arguments such as the arguments object, and also the nature of the this keyword, as well as the variable scope chain as well as the prototype chain, but for now this is just the basic section.
In other words something like this.
Pure functions are functions that only work with what is given via a set of arguments, and not anything that that is a global variable of object class instance. They also do not mutate and object that is given in place but return a new object.
I have all ready covered constructor functions and how the this keyword applies there, but I should also at least mention that the this keyword can come into play outside of that of constructor functions. For example the Call function prototype method can be used to change what the value of the this keyword is, thus it is a way to break methods out of there prototypes and get them to work on any object to which it might in fact work with or without problems.
One way to start playing around with the this keyword outside of that of constructor function is to create a method that works just like a prototype method, but just make it part of a single stand alone object rather than that of a prototype object.
The call method of the function prototype can be called off of any function as any function is an instance of the function constructor and therefor prototype methods are there to work with. By calling the call method off of a function the first argument that I pass to call is a value that will be used as the value of the this keyword in the body of the function, after the first argument I can then continue passing arguments like normal.
Another topic that might come up with functions is the topic of inverse functions. An inverse function, or anti function, is a kind of function that is the inversion of another function. These kinds of functions will come all the time, often I have a way to go about getting a unknown value say x, with a known y value, other times I have y actually and now I actually need a way to get x with y. for example say I have a function that will return a position given a distance and angle, and inversion of that function would be a function that gives a distance and angle for a given position. So then in this section I think I should go over at least a few quick examples of this kind of function.
For a basic example of an inverse function say I have a function that will just return a value that can be called x, by multiplying an argument called y by 5. In that case the inverse of such a function would be a function that will divide x by 5 to get y.
The domain of a function is often describe as the full range of possible argument values for a function. If the range of possible values is small enough, and there is just one argument some times it is possible to test out the full range. Other times it is just a small range of values that can be tested, or a stepping value will need to be used when the range is to extreme for practical testing purposes.