Unit 1 Glossary - SEIR-59/course-wiki GitHub Wiki
A page for terms and definitions significant to Unit 1.
Formatting Notes*: Please keep this page in ALPHABETICAL order, use Heading 2 (h2) for the word titles, and source your information if it isn't your own words. If it is your own words, be sure it's right, but hey, thats what a wiki is for, right? Be sure and leverage the "Preview" tab instead of saving to check your formatting so the edits are clear.
*If you aren't familiar with markdown editing, click the ? in the toolbar above or use buttons provided for basic formatting
Argument
The values for the parameters we pass into a function when we invoke it.
function sayWord(word){
console.log(word);
}
// in the function invocation below, the string "hello" is the argument
sayWord("hello"); // "hello"
Default (or Optional) Parameters
We can define parameters that will default to pre-determined values if the function is called without passing them in.
function sayWord(word = ‘hello’){
console.log(word);
}
sayWord(‘goodbye’); // “goodbye”
sayWord(‘bonjour’); // “bonjour”
sayWord(); // “hello”
For Loop
When a block of code is executed a particular number of times.
for (let i = 0; i < 10; i++) {
console.log(i)
}
Function Reference
When we pass a function as an argument for another function.
function sayHello(){
console.log("hello world!");
}
// below, we are adding an event listener on a button and the event listener is referencing our sayHello function. So, now, when we click the button, the sayHello function will be invoked.
btn.addEventListener('click', sayHello)
Recursion
Recursion is when a function calls itself from within.
function recursion(){
if (condition) {
// Code to execute
recursion();
// Function called within itself after condition is met
} else {
return;
// Breaking recursion loop
}