Skip to content

Commit 0d55280

Browse files
committed
adds this.js
1 parent 91da73c commit 0d55280

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎src/this.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@ const checkPassword = function comparePasswords(passwordToCompare) {
3232
// use `this` to access the object's `password` property.
3333
// do not modify this function's parameters
3434
// note that we use the `function` keyword and not `=>`
35-
this.password === passwordToCompare;
35+
return me.password === passwordToCompare;
3636
};
3737

3838
// invoke `checkPassword` on `me` by explicitly setting the `this` context
3939
// use .call, .apply, and .bind
4040

4141
// .call
42-
comparePasswords.call(this.password, me.password);
42+
console.log(checkPassword.call(me.password, 'correcthorsebatterystaple')); // True
4343
// .apply
44-
comparePasswords.apply(this, me[password]);
44+
console.log(checkPassword.apply(me.password, ['correcthorsebatterystaple'])); // True
45+
console.log(checkPassword.apply(me.password, ['naybor'])); // False
4546
// .bind
46-
comparePasswords.bind(this, comparePassword(me));
47+
const bindCheckPassword = checkPassword.bind(me);
48+
console.log(bindCheckPassword('correcthorsebatterystaple')); // True

0 commit comments

Comments
 (0)