Please enable JavaScript.
Coggle requires JavaScript to display documents.
Functions in JavaScript - Coggle Diagram
Functions in JavaScript
1.1 Definition
- Snippet of code to perform a specific action
- Can be executed (called) by other code or itself
- Invoked with:
functionName()
-
1.3 Ways to Create
-
- Function Expression (focus in this lesson)
1.4 Naming Convention
- camelCase →
updateUser, calculateAgeInMinutes, cube
2.1 Syntax
-
function → reserved keyword
-
-
2.2 Invocation
- Both declaration and expression use
functionName()
3.1 Parameters
- Defined in parentheses
()
- Placeholders for input values
3.2 Arguments
- Real values passed when invoking
-
4.1 Return
- Use
return to output a value
- Without
return → undefined
-
-
console.log() → prints values
-
Math.round() → rounds numbers