I only see examples of people passing two functions but nothing on a prop and function simultaneously. Let's say I want the pass onClick={props.tested}
(prop) and onClick={divTested}
(function) at the same time. How do I do this??
Although I rarely see this done, you can indeed add properties to a function, and pass that "function with properties" into another function that is aware of those properties:
let functionWithProperties = function(a, b) { return a + b; } // Add Properties to the function: functionWithProperties.a = 5; functionWithProperties.b = 10; function doSomethingWithFunctionWithProperties(func) { return func(func.a,func.b); } // Pass function with properties into another function // that is aware of those properties: let output = doSomethingWithFunctionWithProperties(functionWithProperties); console.log(output); // 15
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.