I have a constructor object that has various fields; For a simple example, say
function Person(id, name) {
this.id = id;
this.name = name;
etc.
this.someFunction = function(xxx) {...}
}
Now, I have an arbitrary object with an id and name field
var somePerson = {id:123, name:"joe"}
I would like to inject the data from the somePerson instance into a Person constructor, so I can apply all of the methods from the Person class, but I am confused between apply, call, and bind.
I am aware that I can call a new constructor passing in all of the fields, but there are a lot of fields. Is there any easy way to just endow the somePerson instance with the methods from the Person class?