Home > Software design >  Why does let generate error but var doesnt
Why does let generate error but var doesnt

Time:03-30

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);
  }
}

CodePudding user response:

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

  • Related