JSFiddle - React, Tailwind, and code Playground
JavaScript
/* Literal functions */
var myObject = {
iAm : 'an object',
whatiAm : function(){
alert('I am' + this.iAm);
},
};
myObject.whatiAm();
/* Constructive Function */
var myObject = function(what){
this.iAm = what;
this.whatiAm = function(language){
alert('I am ' + this.iAm + ' and my language is ' + language );
};
};
var myObject2 = new myObject('amitabha');
myObject2.whatiAm('javascript');