if..else vs if(){return}

Viewed 23804

In the following example - given that the return value isn't of any importance - is there a reason to prefer either method over the other?

// Method 1
function (a, b) {
  if (a == b){
    // I'm just interested in
    // the stuff happening here
  } else {
    // or here
  }
return true;
}

// Method 2
function (a, b) {
  if (a == b){
    // I'm just interested in
    // the stuff happening here
    return true;
  }
  // or here
  return true;
}
6 Answers
Related