CS401A's Pre-Finals: Fundaments of Web Prog. Module 06 Flashcards
For pre-final and final exams.
is a separate piece of code intended to perform a specific task.
A function in JavaScript
It is usually assigned a specific name that is called many times in different program sections.
A function in JavaScript
It also encloses a repeated sequence of instructions in the program to increase the code’s readability.
A function in JavaScript
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.
A JavaScript function
It also allows for easy testing of code fragments enclosed in functions independent from the rest of the program.
A JavaScript function
Declaring Functions
starts with the function keyword followed by the function name, which follows the same rule as variable names that must relate to the condition to be done.
A function statement
Declaring Functions
It is then followed by parentheses that enclose function parameters.
A function statement
Declaring Functions
It is followed by the function body, which contains the code block.
A function statement
Calling Functions
To call a function, the function name is
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.
return Functions
The return keyword
It also allows programmers to return a given value from inside the function to the place where it was called.
return Functions
The return keyword
return Functions
is only usable inside its corresponding function block,
is usually declared inside a function,
A local variable
return Functions
is usable anywhere in the program.
is declared outside any block or function
while a global variable
are names seperated by commas, placed inside the parenthesis after the function name, and treated as local variables.
Parameters
Parameters
they refer to the values given when a function is called.
Recalling arguments,