Does eval() run in strict mode in methods?
class A { b() {eval("with(this) { 1 } ")} }
new A().b()
// strict mode error
But not in functions?
function b() {eval("with(this) { 1 }")}
b()
> 1
Does eval() run in strict mode in methods?
class A { b() {eval("with(this) { 1 } ")} }
new A().b()
// strict mode error
But not in functions?
function b() {eval("with(this) { 1 }")}
b()
> 1
This is explicitly stated in docs MDN, ES2017.
The bodies of class declarations and class expressions are executed in strict mode i.e. constructor, static and prototype methods, getter and setter functions are executed in strict mode.