Home > Article > Web Front-end > Methods and codes for obtaining external function names in js classes_js object-oriented
For example, if we want to set a method in a class, we can call a method and save it in a class variable. When needed, we can get it by accessing the class variable.
Usually if we generate an instance
such as: var temp=new TopnetTree();
If we pass in a method by setting attributes, we will find that what is passed in is the content of a function. rather than the function name.
For example, temp.fileAction=fnTest; //fnTest is a function
So I wrote a method to implement this function.
Judge the incoming content through arguments:
Achieve the following functions:
The incoming content is empty and nothing is executed
Passing in a parameter means it is a parameterless function
If multiple parameters are passed in, it means that the first parameter is the function name, and the following parameters are each parameter.