KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have this JavaScript: var Type = function(name) { this.name = name; }; var t = new Type(); Now I want to add this: var wrap = function(cls) { // ... wrap constructor of Type ... this.extraField = 1; }; So I can do: wrap(Type); var t = new Type(); assertEquals(1, t.extraField); [EDIT] I'd like an instance property, not a class (static/shared) property. The code executed in the wrapper function should work as if I had pasted it into the real constructor. The type of Type should not change.
Tags (comma-separated)
Save Edits
Cancel