Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Example of _.extend


Person = function(attributes)
{
this.attributes = attributes;
}


_.extend(Person.prototype, {test: function(){return _.clone(this.attributes)}});

const s = new Person("some test text");
 console.log(s.attributes);
 console.log(s.test());
 /*the key to getting attributes to display is using a function(){} and _.clone()*/
/*just test: this.attributes will be undefined*/
 
PREVIOUS NEXT
Tagged: #Example
ADD COMMENT
Topic
Name
5+2 =