Question:

dude = {
  greet: "hi",
  bye: "peace"
}

function a () {
  return this.greet + ", " + this.bye;
}

console.log(a.apply(dude));

Answer:

"hi, peace"

The apply() method is defined for function objects and accepts an object as the first parameter. The object that's passed to apply() as an argument is assigned to "this" when the function is invoked.


Keywords:

© 2017 QuizBucket.org