clearTimeouts vs check if null first

Edit on GitHub

Setup

var timeoutReference;

Tests

  • clearTimeouts

    clearTimeout(timeoutReference);
    timeoutReference = setTimeout(function(){
    //does not care about this
    },200)
  • check if null first

    if(timeoutReference) clearTimeout(timeoutReference);
    timeoutReference = setTimeout(function(){
    //does not care about this
    },200)