var a=function(x){return x*x;} What does a mean that can be put into other functions to operate? Is it called or imported? Can you give an example?
灭绝师太2018-04-20 13:05:34
In the video: var a=function (x){return x*x;}//Assign the function as a value to the variable a
Call the method such as:
var pf=function ( x){return x*x;}//Find the square
var lf=function(x){return x*x*x;}//Find the cube
// Call the function to get the corresponding result
function doFunc(func,value){
return func(value);
}
console.log(doFunc( pf,10));
console.log(doFunc(lf,10));