Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

define methods of objects in javascript

objectName.methodname = functionName;

var myObj = {
  myMethod: function(params) {
    // ...do something
  }

  // OR THIS WORKS TOO

  myOtherMethod(params) {
    // ...do something else
  }
};
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #define #methods #objects #javascript
ADD COMMENT
Topic
Name
8+9 =