Answers for "how to define function in object javascript"

5

how to define function in object javascript

// Functions that are defined inside objects are called methods.
let example = {
  calc: function (num1, num2) {
    return num1 + num2;
  },
};

// Calling the method
example.calc(1,2)
Posted by: Guest on May-26-2021

Code answers related to "how to define function in object javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language