Semi Colon Issue in JS

window.function1 = function() {
  console.log('function 1');
} window.project = 'test';

js engine reads this entire thing as one statement ,since it can't find any semicolon for the anonymous function assignment, it continues parsing only to find window.project = 'test and so it gives you an error.

window.function1 = function() {
  console.log('function 1');
}; window.project = 'test';

here because you have a semicolon after the anonymous function, js engine can figure out that that these are 2 different statements.