我刚刚遇到一个javascript函数 return !1
我只是想知道这究竟是什么意思?
你为什么return !1或者return !0
有人可以解释一下这意味着什么吗?
这是我遇到的功能:
function convertStringToBoolean(a) {
typeof a == "string" && (a = a.toLowerCase());
switch (a) {
case "1":
case "true":
case "yes":
case "y":
case 1:
case !0:
return !0;
default:
return !1
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!