javascript
function
Function
If you are looking to decrease the duplicated codes, then use function().
First of all, you will see why we have to use function() and second of all, you will the different ways of writing function().
This is the worst way of writing codes:
There might be a massive project that you are working and you figure it out that there is something with the codes, so you need to go through all the codes and find out the where the bug is coming from, but with this way:
Now you need to change the code from that function and it effects the whole codebase, interesting right?
I can change the plus to minus or multiplication or something you like very easy, and there is no need to go through the codes and change them manually which is nightmare for you and myself... haha
or even add number to them:
You can do something with this just you need to learn it and use it, it is not that hard.
Once you learn, you will love to work with it all the time.
Different Ways of Writing function()
Function Declaration
Function Expression
Arrow Function
Short Callbacks
This kind of function is not used for large function.