hax / hax/hax.github.com

How you interpret this code? -- test of a imaginary JavaScript code

Open
#44 24 comments 1 reaction 0 assignees View on GitHub
Dominant language
HTML
Stars
464
Forks
27
PR merge metrics
No merged PRs in 30d

Description

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.

注意,下面的代码目前并**不是**合法的代码。所以后面的选择**没有对错之分**,请按照你的直觉选择。

```js
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.

请用表情符号投票。👍 表示跟你的直觉相符,你也可以用 👎 表示完全不会这么想。如果你觉得有其他结果,可以留言。谢谢。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.