Reputation: 32949
I am looking to set an attribute of an object dynamically. Look at the example below.
function testFunc(type, scope){
this.scope = scope;
this.scope.setAttribute(type, true);
this.doSome = function(){return //Something;}
}
but I realized that setAttribute
method is only available for DOM elements. Is there a way i can set an attribute dynamically to a js object ?
Upvotes: 0
Views: 4958
Reputation: 20155
function testFunc(type, scope){
this.scope = scope;
this.scope[type]= true;
this.doSome = function(){return //Something;}
}
should do the trick.
Upvotes: 2