Hoisting Function Statements is so crucial!
With hoisting, the top of the file contains the “what”.
// create a user
.then( check_if_email_is_registered )
.then( store_details_in_db )
.then( send_email_verification );
“This is what happens, this happens after and this is what happens in the end”
At the bottom of the file is the “how”.
// connect to redis
// check in-memory cache of usernames
// return result of check
On jumping into the file, I get the 50,000 foot view of what’s happening and I know where to go when I want to drill into how a certain thing is being done.
Save a JS dev: Hoist your Functions