本文介绍了什么!1和!0在Javascript中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript文件中我不得不今天读到,有一行变量被声明为阶乘,如下所示:

In a JavaScript file I had to read today, there was a line where a variable was declared like a factorial, like this :

var myVariable = !1;

然后在这样的函数中使用类似的东西作为参数:

and then something similar was used as parameter in a function like this :

return variable.myFunction(!0);

任何人都可以解释一下感叹号在这种情况下的含义,并最终解释为什么这通常用于(福利)?

Can anyone explain me what the exclamation mark means in this context and eventually, why this is generally used for (benefits) ?

提前谢谢!

推荐答案

!是布尔运算符。

NOT(!):将语句从true切换为false或从false切换为true。

NOT (!): toggles a statement from true to false or from false to true.

!0 = true
!1 = false

很棒介绍布尔运算符及其在javascript中的使用。

This is a brilliant introduction to boolean operators and their use in javascript.

这篇关于什么!1和!0在Javascript中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 22:18