๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐ ๐๐๐ถ๐ฑ๐ฒ
Functions are blocks of reusable code. They do one task. Think of them as small programs.
Use functions for common actions:
- Button clicks.
- Closing images.
- Shopping cart updates.
A function declaration has four parts:
- The function keyword.
- A name.
- Parentheses for parameters.
- A body with curly braces.
You must call a function to run it. Use the name and parentheses.
Parameters and arguments are different.
- Parameters are empty spots in the definition.
- Arguments are the actual values you send.
The arguments object is a built-in tool. It lists all values you pass to the function.
The return keyword sends a value back. It stops the function. Always place it at the end.
Source: https://dev.to/kamalesh_ar_6252544786997/functions-in-javascript-with-keywords-lk6