Is there any way to dynamically add a constructor to a Class without altering the original Class itself?
I'm using a library where I instantiate objects like so:
var path = new Path()
What I want to do is something like this:
// obviously won't work but you get the point
Path.prototype.constructor = function() {
console.log(this, 'was created')
}
var path = new Path()
I can obviously use a Factory to create my objects and in that Factory I can add a custom function and trigger it. That won't work since the library I'm using won't be using that factory internally.