0

This little situation in JavaScript was driving me crazy. The contents of the SQL string are unimportant. However, the line I commented as [1] simply was not executing. Other lines after it were executing. I tried to power past the problem by duplicating the line in case there was something happening of the form "this line casts a shadow on the line after it". No help. The debugger would not stop for single stepping on lines [1] or [2] and condition and values were coming up undefined.

  var temp = sqlConditionFromChoices(spec)
  var sql = `
  SELECT teams.name FROM teams
  JOIN events ON events.hometeamuuid = teams.id
  `
  [condition, values] = temp  // [1]
  [condition, values] = temp  // [2]

Solution: Add a couple of semicolons.

  var temp = sqlConditionFromChoices(spec)
  var sql = `
  SELECT teams.name FROM teams
  JOIN events ON events.hometeamuuid = teams.id
  `;
  [condition, values] = temp;  // [1]
  [condition, values] = temp  // [2]

All lines executed. But why? Can someone explain what hidden rule was allowing the SQL line to devour the lines following? Does it have something to do with backquoted strings?

Joymaker
  • 813
  • 1
  • 9
  • 23

0 Answers0