The requested page is not available for the requested platform. You are viewing the content for Default platform.

Merge Duplicate Local Declaration (JavaScript)

Merges multiple identical local variable declarations into a single declaration.

Availability

Available from the context menu or via shortcuts:

  • when the cursor is on a variable name within its declaration, provided that there are several declarations of this variable in the current scope.

Examples

function GetClicksCount() {
  var clicks = GetClicks();
  ProcessClicks(clicks);
  var clicks = GetProcessedClicks();
  if (AllClicksProcessed === 0) {
    var clicks = GetUnProcessedClicks();
    ReportUnprocessedClicks(clicks);
  }
  return clicks;
}

Result:

function GetClicksCount() {
  var clicks = GetClicks();
  ProcessClicks(clicks);
  clicks = GetProcessedClicks();
  if (AllClicksProcessed === 0) {
    clicks = GetUnProcessedClicks();
    ReportUnprocessedClicks(clicks);
  }
  return clicks;
}

Screenshot

JScriptMergeDuplicateLocalDeclaration