This section describes how to transmit parameters in javascript Functions. If you have any questions about parameter transfer, you may find yourself confused when passing function parameters, the reason is none. That is, its syntax is too weird. You define a function.
For example
Function test (name, msg) {return 'hello' + name + msg ;}
So how do you call it? You can test ('Eric '), test ('Eric', 'Welcome to javascript ') you can even pass any number of parameters to it, and the type is random. this is a great thing. If you have studied c ++/c # or java, you may think of function overloading. However, what I want to tell you is that there is no function overload in javascript. If you define two functions with the same name, the first defined function will be overwritten by the second defined function, this means that the result you want can only be obtained from the function defined later.
Well, let's get down to the point. Why can javascript function transmission be so casual? Let's take a look at where all the passed parameters are stored. In fact, in its internal implementation, all the passed parameters exist in an array. The function always receives this array, regardless of the parameters contained in the array. Now we can understand it. We have defined a function. When calling this function, you can upload parameters as needed. If you do not upload any parameters, you can add them to the array, if all your parameters are 'undefined', there is no syntax error, but it is hard to say it in semantics.
All right, the first time I wrote a blog, I hope this blog post will help you a little bit ....
I LOVE YOU, GUYS!