Sobes.tech
Junior — Senior

What will the console output in example №9

livecode

Task condition

Determine which values will appear in the console when executing the following JavaScript code:

var a = {
  firstName: 'Bill',
  lastName: 'Ivanov',
  sayName: function() {
    console.log(this.firstName);
  },
  sayLastName: () => {
    console.log(this.lastName);
  }
};

 a.sayName(); //

var b = a.sayName;
 b(); //

a.sayName.bind({ firstName: 'Boris' })(); //

a.sayName(); //

a.sayLastName(); //

a.sayName.bind({ firstName: 'Boris' }).bind({ firstName: 'Tom' })(); //

a.sayLastName.bind({ lastName: 'Petrov' })(); //