This is not the case for anonymous JS classes un Scala.js. an invocation like
val o = new Foo {
var x = 5
}
where Foo <: js.Any
will not create an independent class. It will create an instance of Foo
(or its parent class if Foo
is a trait) and patch x
directly on the instance.
This is a very important use case for interoperability purposes in Scala.js, which can be fairly common in code interoperating with JavaScript. That use case has to stay convenient, and must not be confused with declaring a local object
(which does create an independent class).