Q:

javascript method

// 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
2

var person = {

    firstName: "John",

  lastName : "Doe",

  id       : 5566,

  fullName : function() {

    return this.firstName + " " + 
this.lastName;
  }

};
 
1
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.
1

New to Communities?

Join the community