title: Avoid Memory Leak / Usage Javascript
body: <p>I am newbie to jQuery. I am bit confused whether is it fine or may cause memory leak ?</p>
  
  <p>Here is the code: This method is called on certain date filters for each new values </p>
  
  <pre><code>function preapreTooltip(chart) {
      var tickLength = chart.xAxis[0].tickPositions.length,
          ticks = chart.xAxis[0].ticks,
          tickPositions = chart.xAxis[0].tickPositions;
      for ( var iCntr = 0; iCntr &lt; tickLength; iCntr++) {
           var tickVal = tickPositions[iCntr];
  
      //.label or .mark or both
      (function(tickVal) { // Is this good practice to call function like this?
          ticks[tickVal].label
          .on('mouseover', function(event) { // Is this good practice to call function like this?
              var label = '', labelCnt=0;
              $(chart.series).each(function(nCntr, series) {
                  //business logic for each series
              });
  
             // calling method to show values in a popup
          });
  
          ticks[tickVal].label.on('mouseout', function(event) { // Is this good practice to call function like this?
              try {
                  hideWrapper(); // hides popup
              } catch (e) {
              // do nothing
              }
          });
  
      })(tickVal);
    }
  }
  </code></pre>