I have a few lines of javascript code as below:
var str = '////';
var re = /^\/+$/g
console.log(str && re.test(str), str && !re.test(str));
The output of the code in Node.js
are false, false
and in Chrome
Client side are true, true
I'm quite confused and would anyone help to understand:
- Why the two boolean statements are both evaluated to
true
orfalse
while they are meant to be opposite? - What's difference between
Chrome
andNode.js
in evaluating the two boolean statements?