Question about anonymous functions
MrSwan
MrSwan 2018-04-20 12:23:51
0
1
1683

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?

MrSwan
MrSwan

reply all(1)
灭绝师太

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));


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template