JSFiddle - React, Tailwind, and code Playground
JavaScript
var car = {
name: 'car',
sound: 'beep',
honk: function () {
alert(this.sound)
}
}
var truck = {
name: 'truck',
sound: 'HONK HONk',
honk: function () {
alert('this ' + this.name + ' goes beep, beep, beep!')
}
}
// wait two seconds cuz jsfiddle loads slow
setTimeout(function () {
car.honk();
car.honk.call(truck);
truck.honk.call(car)
truck.honk();
}, 2000);