Confusion about variables equaling functions JavaScript

53 views Asked by At

I have these functions:

function change(num1, num2){
    //return number
}

function getFunction(funct){
    //return function
}

this declaration:

var funct = getFunction(change);

and this call

funct(array);

I am confused about what the call does. Where does it send array, what exactly is it doing? I just can't wrap my head around it. When sending the function change() into getFunction() what exactly does this do and again how does JS handle funct(array)? Let me know if I need more info.

1

There are 1 answers

3
Sterling Archer On BEST ANSWER

getFunction returns a function.

var funct = getFunction(change);

funct is now assigned to the returned function reference

funct(array) is just calling the function returned from the previous assignment.