JSFiddle - React, Tailwind, and code Playground
by danShumway
JavaScript
function Obj(){
this.setAProperty = function(){
this.x = 5;
}
}
var myObj = new Obj();
//Now when I call the method, "this" refers to the location, the Obj object.
myObj.setAProperty();
//x is added as a property to myObj, the place where the method was found.
alert(myObj.x); //Returns 5.