Is it possible to add a method to an array() in javascript? (I know about prototypes, but I don\'t want to add a method to every array, just one in particular).
The
function drawChart(){
{
//...
var importantVars = [list of important variables];
importantVars.redraw = function(){
//Put code from updateChart function here using "this"
//in place of importantVars
}
return importantVars;
}
Doing it like this makes it so you can access the method directly after you receive it.
i.e.
var chart = drawChart();
chart.redraw();