JavaScript 中的感叹号"!"运算符是什么?

javascriptweb developmentfront end technology

感叹号运算符用于对表达式进行求反。

示例

您可以尝试运行以下代码来了解如何在 JavaScript 中实现感叹号(!)运算符 −

<html>
   <head>
      <title>JavaScript Boolean</title>
   </head>

   <body>
      <script>
         var answer = true;
         document.write(answer);
         document.write("<br>"+!answer);
      </script>
   </body>
</html>

相关文章


有用资源