When I want to create and use a function what accepts another function in it as an argument I usually do:
// Create Function
function doSomething(func){
func();
}
// Call Function
doSomething(function(){
...
});
but in javascript(and many other languages what I know) there a default functions such as if, while, for, function where there is a different format when I call them:
while(i < 10){
...
}
So this while function doesn’t have another “parent” function. Is it possible to make my own functions in this style in javascript?
You can’t do this as they are inbuilt language constructs. You can of course have a function in your global scope but they work just as any other function would.