1) You're creating a new function instance for `SomeClass.method` every single time you create an instance of SomeClass. This will slow down construction.
2) `method` is an instance property, not a prototype property, and so takes up more memory for a reference per instance, plus the memory of the function instance.
3) In that function instance, you're closing over the references to `someClass` and `arg1` even though they're already available in `method` as `this` and `this.arg1`, also increasing the memory of instances.
4) Setting method will cause an unnecessary hidden-class transition.
If you really want to hide `secretArg`, use a WeakMap:
const secrets = new WeakMap();
class SomeClass {
constructor(arg1, secretArg) {
this.arg1 = arg1;
this.bar = undefined;
secrets.set(this, secretArg);
}
method(foo) {
this.bar = foo;
const secret = secrets.get(this);
secret.count++;
}
}
This will result in much lighter weight instances.