What is an exclamation “!” operator in JavaScript?


The exclamation operator is to perform negation on an expression.

Example

You can try to run the following code to learn how to implement exclamation(!) operator in JavaScript −

Live Demo

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

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

Updated on: 15-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements