TheWizEd
TheWizEd

Reputation: 8606

Why does let generate error but var doesnt

In Google App Script both old and new editor this causes an error

function sortSheets() {
  try {
    let ss = SpreadsheetApp.getActiveSpreadsheet();
  }
  catch(err) {
    console.log(err);
  }
}

Syntax error: Missing ; before statement. line: 16 file: Code

But this does not.

function sortSheets() {
  try {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
  }
  catch(err) {
    console.log(err);
  }
}

Upvotes: 1

Views: 315

Answers (1)

TheWizEd
TheWizEd

Reputation: 8606

I completely forgot about the V8 runtime. When off I get that message, obviously because the old runtime did not have let.

enter image description here

Upvotes: 1

Related Questions