๐จ๐ป๐ฑ๐ฒ๐ฟ๐๐๐ฎ๐ป๐ฑ ๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐
A function is a block of code. It performs a specific task.
Stop repeating your code. Put it in a function. Call it when you need it.
Learn these two terms:
- Parameters: Variables you write when you create a function.
- Arguments: Real values you pass when you call a function.
Example: Parameters: rice, masala, chicken. Arguments: Basmati Rice, Spicy Masala, Chicken.
Use return to send a value back from a function.
JavaScript uses hoisting. It moves declarations to the top before the code runs.
- Function declarations move fully. You call them before they appear in the code.
- Var declarations move but stay undefined.
- Let and const do not work this way.
Source: https://dev.to/raja_b_0c9d242e2c26cf063b/function-3bjd