JS-040
Visual JavaScript guide to Logical NOT : Learn to use the ! operator to change true to false and false to true
Beginner3 min~3 min read#logical-not#not#boolean

Logical NOT !

Changes true to false

Goal

Learn to use the ! operator to change true to false and false to true.

Explanation

  • The ! operator means logical NOT.
  • It changes a Boolean value to its opposite.
  • !true returns false.
  • !false returns true.
  • NOT is often used to check the opposite of a condition.

Analogy

Imagine a light switch. If the light is on, the ! operator turns it off. If it is off, the operator turns it on.

Code

console.log(!true);
console.log(!false);

Result: false true

Common mistake

Beginners sometimes think ! only checks a value. In fact, it returns the opposite Boolean value.

Remember

  • ! changes a value to its opposite.
  • !true → false.
  • !false → true.

Quick Quiz

What does !false return?

Resources