CS401A's Pre-Finals: Fundaments of Web Prog. Module 06 Flashcards
For pre-final and final exams. (16 cards)
is a separate piece of code intended to perform a specific task.
Function Syntax (OpenEDG, 2023)
A function in JavaScript || A JavaScript function
It is usually assigned a specific name that is called many times in different program sections.
Function Syntax (OpenEDG, 2023)
A function in JavaScript || A JavaScript function
It also encloses a repeated sequence of instructions in the program to increase the code’s readability.
Function Syntax (OpenEDG, 2023)
A function in JavaScript || A JavaScript function
aims to divide the code into logically independent parts to make a long program that is not a sequence of instructions easier to write and understand.
Function Syntax (OpenEDG, 2023)
A function in JavaScript || A JavaScript function
It also allows for easy testing of code fragments enclosed in functions independent from the rest of the program.
Function Syntax (OpenEDG, 2023)
A function in JavaScript || A JavaScript function
Declaring
starts with the \_\_\_\_\_\_\_\_
keyword followed by the \_\_\_\_\_\_\_\_
name, which follows the same rule as variable names that must relate to the condition to be done.
Function Syntax (OpenEDG, 2023)
Functions
A function statement
function
function
Declaring
It is then followed by parentheses that enclose \_\_\_\_\_\_\_\_ \_\_\_\_\_\_\_\_\_\_
.
Function Syntax (OpenEDG, 2023)
Functions
A function statement
function parameters
Declaring
It is followed by the \_\_\_\_\_\_\_\_
body, which contains the code block.
Function Syntax (OpenEDG, 2023)
Functions
A function statement
function
Calling
To call a function, the function name is
Function Syntax (OpenEDG, 2023)
Functions
written followed by parentheses and the instruction it should do next.
causes the function to end exactly wherever this word is placed in the instruction.
Function Syntax (OpenEDG, 2023)
return Statement
The return keyword
It also allows programmers to return a given value from inside the function to the place where it was called.
Function Syntax (OpenEDG, 2023)
return Statement
The return keyword
return Statement
Side note:
is only usable inside its corresponding function block,
is usually declared inside a function,
Function Syntax (OpenEDG, 2023)
A local variable
return Statement
Side note:
is usable anywhere in the program.
is declared outside any block or function
Function Syntax (OpenEDG, 2023)
while a global variable
These are only optional to use in functions.
Function Syntax (OpenEDG, 2023)
Parameters
are names seperated by commas, placed inside the parenthesis after the function name, and treated as local variables.
Function Syntax (OpenEDG, 2023)
Parameters
Parameters
they refer to the values given when a function is called.
Function Syntax (OpenEDG, 2023)
Recalling arguments,