Skip to content

Commit f281387

Browse files
committed
this.js:part 2 completed
1 parent 1b416d4 commit f281387

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/this.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ const checkPassword = function comparePasswords(passwordToCompare) {
3737
// use `this` to access the object's `password` property.
3838
// do not modify this function's parameters
3939
// note that we use the `function` keyword and not `=>`
40+
if (this.password === passwordToCompare) {
41+
return true;
42+
}
4043
};
4144

4245
// invoke `checkPassword` on `me` by explicitly setting the `this` context
4346
// use .call, .apply, and .bind
4447

4548
// .call
46-
49+
console.log(checkPassword.call(me, 'correcthorsebatterystaple'));
4750
// .apply
48-
51+
console.log(checkPassword.apply(me, ['correcthorsebatterystaple']));
4952
// .bind
53+
const bindMoi = checkPassword.bind(me, 'correcthorsebatterystaple');
54+
console.log(bindMoi());

0 commit comments

Comments
 (0)