In Javascript all declarations (var, let, const, function, function*, class) are hoisted but it should be declared in same scope.
As you told "ES6 classes are just a syntactical sugar over JavaScript's existing prototype-based inheritance"
So Let's understand what it is?
Here you declared a class which is in fact "special function".Let's assume that your function Foo() and class Foo both are in global scope.
class Foo {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
Following is the compiled code of your class Foo.
var Foo = (function () {
function Foo(x, y) {
this.x = x;
this.y = y;
}
return Foo;
}());
Internally your class is converted to function with the same name inside wrapper function(iife) and that wrapper function returns your function.
Because your function's(class) scope is changed. and you are trying to create object of function in global scope which is in reality not exist.
you get the function in variable Foo once compilation comes to that. so later you have function in var you can create object of that.