JSFiddle - React, Tailwind, and code Playground
by Tushar Jadhav
HTML
<p>Creating and using an object method.</p>
<p>An object method is a function definition, stored as a property value.</p>
<p id="demo"></p>
JavaScript
var person = {
firstName: "Sunil",
lastName: "Kumar",
id: 5566,
fullName: function fullName() {
return this.newName(this.firstName + " " + this.lastName);
},
newName: function newName(nm) {
return 'new ' + nm;
}
};
document.getElementById("demo").innerHTML = person.fullName();