Skip to content

Commit 2eea483

Browse files
authored
fix tabs in code examples
1 parent 1252808 commit 2eea483

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

51 - Prototypal Inheritance Review.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ What I wanted to do in this video is do a quick review of how prototypal inherit
55
What I want to do here is let's make a dog function that will create puppies or create many dogs:
66

77
```js
8-
function Dog(name, breed) {
9-
this.name = name;
10-
this.breed = breed;
11-
}
8+
function Dog(name, breed) {
9+
this.name = name;
10+
this.breed = breed;
11+
}
1212
```
1313
Notice we're using a capital D on `Dog` because this is what's called a constructor function. The function itself will pass in whatever we get for name and breed are assigned as `name`, and `breed`.
1414

@@ -41,14 +41,14 @@ Where did they come from? Well, we have the "Mama array", which is capital A, `A
4141
We're going to take a look at how they don't just take their own, they actually share the same one. Let's add a prototype method to our `Dog`:
4242

4343
```js
44-
function Dog(name, breed) {
45-
this.name = name;
46-
this.breed = breed;
47-
}
48-
Dog.prototype.bark = function() {
49-
console.log(`Bark Bark! My name is ${this.name}`);
50-
}
51-
const snickers = new Dog('Snickers', 'King Charles');
44+
function Dog(name, breed) {
45+
this.name = name;
46+
this.breed = breed;
47+
}
48+
Dog.prototype.bark = function() {
49+
console.log(`Bark Bark! My name is ${this.name}`);
50+
}
51+
const snickers = new Dog('Snickers', 'King Charles');
5252
```
5353

5454
Remember, we're using template strings to call `this.name`, because we want to reference the name of the actual dog. If you run `snickers.bark()` in your console, it says, "Bark, bark. My name is Snickers." Makes sense.
@@ -63,26 +63,26 @@ If we run `sunny.bark()`, It returns "Bark, bark. My name is Sunny." You see how
6363
What's really cool about that is you can still change it after the fact:
6464

6565
```js
66-
function Dog(name, breed) {
67-
this.name = name;
68-
this.breed = breed;
69-
}
70-
Dog.prototype.bark = function() {
71-
console.log(`Bark Bark! My name is ${this.name}`);
72-
}
73-
const snickers = new Dog('Snickers', 'King Charles');
74-
const sunny = new Dog('Sunny', 'Golden Doodle');
75-
76-
Dog.prototype.bark = function() {
77-
console.log(`Bark bark! my name is ${this.name} and I'm a ${this.breed}!`);
78-
}
66+
function Dog(name, breed) {
67+
this.name = name;
68+
this.breed = breed;
69+
}
70+
Dog.prototype.bark = function() {
71+
console.log(`Bark Bark! My name is ${this.name}`);
72+
}
73+
const snickers = new Dog('Snickers', 'King Charles');
74+
const sunny = new Dog('Sunny', 'Golden Doodle');
75+
76+
Dog.prototype.bark = function() {
77+
console.log(`Bark bark! my name is ${this.name} and I'm a ${this.breed}!`);
78+
}
7979
```
8080

8181
Even though I've created `snickers` before I've added this method should it still do this? Absolutely. What if I added a second method onto it after the fact?
8282

8383
```js
84-
Dog.prototype.cuddle = function() {
85-
console.log(`I love you owner!`);
84+
Dog.prototype.cuddle = function() {
85+
console.log(`I love you owner!`);
8686
}
8787
```
8888

@@ -92,4 +92,4 @@ If you just `snickers` in your console and you open it up and you won't see `bar
9292

9393
But `bark` and `cuddle` are on the prototype, which means that they're not part of the actual object, `snickers`. But if you open that it up, you'll see `bark` and `cuddle` are right inside of `__proto__` in your DevTools.
9494

95-
With that in mind, let's learn about how we can also do this sort of thing when we write classes.
95+
With that in mind, let's learn about how we can also do this sort of thing when we write classes.

0 commit comments

Comments
 (0)