impactbyte-haku / projects

🌐 Projects
https://gitlab.com/impactbyte/learn/course-fullstackweb
10 stars 1 forks source link

Project JavaScript this #26

Open mhaidarhanif opened 5 years ago

mhaidarhanif commented 5 years ago

Submit here.

mhaidarhanif commented 5 years ago
const vehicle = {
  drive() {
    console.log(`Driving a ${this.maker} ${this.model} car!`)
  },

  sell() {
    console.log(`Selling a ${this.maker} ${this.model} car!`)
  }
}

const car = {
  maker: 'Tesla',
  model: 'S'
}

const bike = {
  maker: 'Heboh',
  model: 'BMX'
}

const driveCar = vehicle.drive.bind(car)
const driveBike = vehicle.drive.bind(bike)

const sellCar = vehicle.sell.bind(car)

driveCar()
driveBike()

sellCar()
arifinoid commented 5 years ago

https://github.com/arifinoid/project-javascript-this

dickymr commented 5 years ago

https://github.com/dickymr/project-javascript-this

nchristanto commented 5 years ago

https://github.com/nchristanto/project-javascript-this

yevgenysiregar commented 5 years ago

https://github.com/yevgenysiregar/project-javascript-this