Note, this is NOT a valid code as current JavaScript syntax. So the choices below are not correct or wrong, please just choose what your intuition tell.
注意,下面的代码目前并不是合法的代码。所以后面的选择没有对错之分,请按照你的直觉选择。
var foo = 0;
class Whatever {
var bar;
constructor(v) {
bar = v;
}
test() {
++foo;
++bar;
return `${foo}:${bar}`;
}
}
var x = new Whatever(10);
x.test(); // output 1:11
var y = new Whatever(20);
y.test(); // output 2:21
x.test(); // output?
y.test(); // output?
Please use 👍 or 👎 to vote. Use 👍 to choose what match your intuition, you could also use 👎 to denote you will never interpret the code like that. If you have other answer, please add comment. Thank you.
请用表情符号投票。👍 表示跟你的直觉相符,你也可以用 👎 表示完全不会这么想。如果你觉得有其他结果,可以留言。谢谢。