In V8, I would like to modify the prototype of the global built-in Array object, by adding some functions to it. In JavaScript, I would do it like this, for example:
Array.prototype.sum = function() {
// calculate sum of array values
};
How can I achieve the same result in C++? I have some global function templates added to the global ObjectTemplate, but I am not sure how to do the same for a supposedly existing native object prototype.
native implementation:
assignment to prototype (notice we need a prototype of a prototype for some reason)
javascript usage: