its more of the console log that i found hilarious for some reason, I think its just imagining the computer finding that 2+2 not equaling 4 after a million times of checking funny. (edit: and the frowny face XD)
I’m having trouble understanding the benefits of declaring a function as a variable as described in the lesson. In the example for this course, the variable busy was declared to be a shorter name for announceThatIAmDoingImportantWork() so then it can be called with busy() instead. In what case scenario(s) would it be advantageous to do this? Wouldn’t it just be simpler to declare a function with the simple name instead of having a complex name and renaming it later on?
A function should always have a descriptive name, so that you know what the function (roughly) does without having to through the code (a comment/type hint with the returned possible data type(s) then also helps). Preferable the name should not be too long, but should be descriptive. always a tricky balance.
we are not renaming the function. We declare another variable which points to the same function in memory.
The shortName variable holds a reference to the thisIsAnUnnecessarlyLongName function. So, if we were to log the place in the memory where shortName and thisIsAnUnnecessarlyLongName are being held, they would point to the same place
I don’t really understand what it means when we say that it holds a reference to the thisIsAnUnnecessarlyLongName function
I also thought that if we changed the value of thisIsAnUnnecessarlyLongName, shortName's value would also be altered
which will execute the function. Both variables point to the same memory/memory address.
Not sure how many times I have done this analogy, but it helps understanding so here it goes:
Imaging the house you live in. The house (function) has an address. You can hand out/give the addresses to two (or more) more friends (variables), but there is still only one house
ok, so when you invoke shortHand you are actually invoking iHaveAnUnnecessarlyLongName, and when you try to access shortHand (like when you try to log shortHand.name), you are actually accessing iHaveAnUnnecessarlyLongName?