Writing Javascript – Functions for newbie

Hello!

This is a question that might be stupid, but trying to wrap my head around writing JS is taking it's toll.
So look at this code block from codecademy JS intro course, using function as a parameter inside another function:

const higherOrderFunc = param => {
  param();
  return `I just invoked ${param.name} as a callback function!`
}
 
const anotherFunc = () => {
  return 'I\'m being invoked by the higher-order function!';
}
 
higherOrderFunc(anotherFunc);

Is there a structural convention that the higher-order function is declared first? Logically in my head you would declare the anotherFunc first, then the higherOrderFunc, because that is using the other one. As a metaphor: Baking a cake you would get all specific ingredients ready first, then put it all together.
This is just a question out of curiosity, and trying to understand the "unwritten rules", because I know they are as important as actual coding ...
Was this page helpful?