driveCar()
function using call()
function, this
will refer to the object that will be passed.
In this case: john
objectlet john = {
firstName: 'John',
lastName: 'Doe'
}
function driveCar() {
document.write(this.firstName + ' ' + this.lastName + ' is driving a car<br/>')
}
driveCar.call(john)