Skip to content

Commit 15c9506

Browse files
committed
added this
1 parent 38156b4 commit 15c9506

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,30 @@
1212
* In class we will be going over the principles listed above and you will be expected to follow along when the instructor asks you to do so.
1313

1414
### Recursion
15+
#### What it is
1516
* recursion is another way to represent a looping program.
1617
* Simliar to a `for loop` or a `while loop` a recursive function will loop until you tell it to stop.
1718
* when solving complex algorithms recursion comes in handy. It is not that great for smaller, less complex algorithms.
18-
* For every recursive function, you'll need to establish what is called a `base case`. A `base case` is a condition that when triggered, will discontinue the call to your function.
19+
* For every recursive function, you'll need to establish what is called a `base case`. A `base case` is a condition that when triggered, will discontinue the call to your function.
20+
21+
### The "this keyword
22+
* Because JavaScript is both an Object Oriented and Functional Programming language, it has some very interesting concepts built into it.
23+
* The 'this' keyword is one of those querky concepts that tend to trip up a lot of people coming into JavaScript.
24+
* You can think of this, as a Pointer to an object. For example, you can use the this keyword to reference an object without having to refer to that object's name.
25+
* **example**
26+
```
27+
const myObj = {
28+
name: 'Freddy'
29+
greet: function() {
30+
console.log(`hello my name is ${this.name}`);
31+
}
32+
};
33+
myObj.greet();
34+
```
35+
* In the above example the "this" keyword becomes active when a person's name is called.
36+
* Tyler McGinnis' four rules to the 'this' keyword. [found here](https://www.youtube.com/watch?v=zE9iro4r918)
37+
1. Window Binding
38+
2. Implicit Binding
39+
3. New Binding
40+
4. Explicit Binding
41+

this.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* The for principles of "this";
2+
* in your own words. explain the four principle for the "this" keyword below.
3+
*
4+
* 1.
5+
* 2.
6+
* 3.
7+
* 4.
8+
*
9+
* write out a code example of each explanation above
10+
*/
11+
12+
// Principle 1
13+
14+
// code example for Window Binding
15+
16+
// Principle 2
17+
18+
// code example for Implicit Binding
19+
20+
// Principle 3
21+
22+
// code example for New Binding
23+
24+
// Principle 4
25+
26+
// code example for Explicit Binding

0 commit comments

Comments
 (0)