What is an exclamation “!” operator in JavaScript?

JavascriptWeb DevelopmentFront End Technology

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>
raja
Updated on 15-Jun-2020 07:12:10

Advertisements