JSFiddle - React, Tailwind, and code Playground
by rhodee
JavaScript
//Method Invocation Pattern
//create an object literal
var myObject = {
points: 2,
//important! when a funciton is created as a property AND
// has access to this has ability to retrireve or modify
score: function (inc) {
// a funtion for scoring stuff
this.points += inc;
return this.points;
}
};
//run the score method directly on the object
myObject.score(10);
//direct access to the state property too
alert(myObject.points);