JS中的条件一元响应不一致

时间:2018-11-25 12:35:05

标签: javascript node.js

为什么要这段代码:

var score = 0;
score = ("H".charCodeAt(0) === "H".charCodeAt(0)) ? score += 1 : score;
console.log("score should be one here and it is = " + score);

虽然以下内容似乎无效:

var score = 0;
score = ("H".charCodeAt(0) === "H".charCodeAt(0)) ? score ++ : score;
console.log("score should be one here but its (zero) = " + score);

从技术上来说我也一样吗?我正在使用nodejs来运行它。

0 个答案:

没有答案