Not Understand the concept

function creategreet(greeting){
function f2(name){
console.log(greeting,name);
}
return f2;
}
let g1=creategreet(‘good morning’);
console.log(typeof g1);

in this code ’ good morning ’ string passes to the function but why the typeof of this function is func.

and please tell about retrun f2 mean.

Type of g1 is a function here since return of creategreet is a function and upon calling it with ‘Good Morning’ argument f2 function s returned first which is saved in g1 now and upon passing any name as argument in g1 it is passed as argument in f2 function