Question:

Demonstrate that the this keyword refers to the object that is being created for functions that are invoked in the constructor invocation context.

Answer:

function Paper() {
  this.whatever = "ok";  // "this" refers to the object that is created by the Paper() function
}
var my_paper = new Paper();
console.log(my_paper.whatever);  // The object created by the Paper() constructor function has a whatever property.  In the body of the constructor function, the "this" keyword refers to the object that is being created and referring to "this" allows properties to be added to the object that is being constructed.

Keywords:

© 2017 QuizBucket.org