title: Closure Function for every class instance (JavaScript)
body: <p>I have to JavaScript class called GKChart :- </p>
  
  <pre><code>class GKChart {   
    constructor(data) {
      try {
        console.info("Enter: Chart Designing initialize function");
        this.chartID = data.id;
        this.chartData = data.data;
        this.chartCall = new chartCalling();
        this.load = this.initialize(this.chartData.config.chartType, this.chartData, this.chartID, this.chartCall);
        this.load();
        this.resize(this.load);
        console.info("Exit: Chart Designing initialize function");
      } catch (err) {
        console.log("Error Found in GKChart Constructoru", err);
      }   
    }
    initialize(chartTypeLoad, chartDataLoad, chartIDLoad, chartCallLoad) {
      try {
        console.log("Start : initialize");
        let chartType = chartTypeLoad;
        let chartData = chartDataLoad;
        let chartID = chartIDLoad;
        var chartCall = chartCallLoad;
        /*Define chart css properties*/
        var loadIt = function() {
          console.warn("Resize Load : "+chartID);
          css(document.querySelector("#" + chartID), {
            'display': 'block'
          });
  
          switch (chartType) {
            case "line":
              {
                chartCall.lineChart(chartData, chartID);
                break;
              }
            case 'bar':
              {
                chartCall.barChart(chartData, chartID);
                break;
              }
            default:
              {
                console.log("Invalid choice of chart");
                break;
              }
          }
        }
  
        return loadIt;
        console.log("End : initialize");
      } catch (err) {
        console.error("Exception occurred in Home module:  " + err.message);
      }
    }
  
    resize(loadFun) {
      try {
          window.addEventListener("resize", function (e) {
            window.resizeEvt;
            window.addEventListener("resize", function () {
              clearTimeout(window.resizeEvt);
              window.resizeEvt = setTimeout(function () {
                loadFun();
                console.warn("ResizeCalled");
              }, 250);
            });
          });
      } catch (err) {
        console.log("error occured while resizing the chart");
      }
    }
  }
  </code></pre>
  
  <p>And i want to call this class for more then 20 instances with some dome data</p>
  
  <pre><code>new GKChart({id: "stepChartComparision", data: stepChartComparision});
  new GKChart({id: "stepChartFill", data: stepChartFill});
  new GKChart({id: "stepChartComparisionFill", data: stepChartComparisionFill});
  ...
  ...
  ...
  </code></pre>
  
  <p>So for these all calls i am drawing some canvas charts.
  To make these canvas charts responsive i have to draw every chart for resize. So i have tried to create a closure function to keep a copy of "this.load" function, but as i can see its only calling once for the last instance.</p>
  
  <p>Please help me to get it for every instance of call, or in other words i want to resize every singe canvas chart.</p>
  
  <p>Thank you.</p>