Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

create instance method javascript

//to create an instance method on a js class 

class nameOfClass {}

nameOfClass.prototype.nameOfInstanceMethod = function (){}

// now the class 'nameOfClass' has a property called nameOfInstanceMethod inside it's prototype chain

console.dir(nameOfClass) //to view it inside the prototype chain

 
PREVIOUS NEXT
Tagged: #create #instance #method #javascript
ADD COMMENT
Topic
Name
7+9 =