Thursday, March 13, 2014

"this" in JavaScript

"this" in JavaScript = a referral to the parent object

adding & removing "this" was the easiest way for me to understand

function OpenStudioModel(buildingData, runmanager) {
  this.model = new openstudio.model.Model();
  this.runManager = runmanager;

"this" is a replacement of OpenStudioModel function
"this" is the current instance of OpenStudioModel
"this" is adding functionality to OpenStudioModel function
"this" is short hand for OpenStudioModel.model & OpenStudioModel.runManager

CodeSchool Definition of "this":  this keyword will automatically refer to the new instance of the class that is being made

No comments:

Post a Comment