Add a method to Array object in Javascript?
javascript
Solution
Arrays are objects, and can therefore hold properties such as methods:
var arr = [];
arr.methodName = function() { alert("Array method."); }
Problem
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 reason I want to do this is because I have the following code ``` function drawChart() { //... return [list of important vars] } function updateChart(importantVars) { //... } var importantVars = drawChart(); updateChart(importantVars); ``` And I want to be able to do something like this instead: ``` var chart = drawChart();<br> chart.redraw(); ``` I was hoping there was a way I could just attach a method to what i'm returning in `drawChart()`. Any way to do that?