// how to make js method!! let monkey = { foods() { console.log('banana'); }, // Don't forget ',' color() { console.log('brown'); } // No input ';' }; monkey.foods(); // banana monkey.color(); // brown
var person = { firstName: "John", lastName : "Doe", id : 5566, fullName : function() { return this.firstName + " " + this.lastName; } };
JavaScript methods are actions that can be performed on syntax. Examples of methods include syntax ending with (); Examples: console.log(); toUpperCase(); Math.floor(); They help change original syntax in various ways.