Standard scenario
In JavaScript, it is not mandatory to provide all arguments when calling a function. If an argument is not passed, the corresponding variable will default to undefined.
Moreover, you can pass more arguments than defined by the function, and then access them using the arguments object. This array-like object contains all the arguments passed to the function. For instance, in the given example, t is essentially a shortcut for arguments[0]. Thus, you can have situations like the following:
function addTwoNumbers(){
return arguments[0] + arguments[1]
}
addTwoNumbers(2,3) //outputs 5
or like this
function retrieveTwo(a,b,c,d) {
return 2;
}
retrieveTwo(); //outputs 2 without any issues
Specific use case
However, the animate() function is invoked within requestAnimationFrame without "t"
It's important to note that the function is not being called without any argument in this scenario. 'animate' is being passed as an argument to another function (which is expected to eventually call the function itself). When a function is referenced without ()
following it, it is being passed as an object rather than executed. Since functions are considered objects in JavaScript, they can be passed to functions like any other object. The following example demonstrates this concept:
function addTwo(x){
return x+2;
}
function utilizeFunction(y,z){
return y(z);
}
utilizeFunction(addTwo,2); //outputs 4