close

How does the double exclamation (!!) work in javascript?

Hello Guys, How are you all? Hope You all Are Fine. Today we are going to learn How does the double exclamation (!!) work in javascript? in javascript. So Here I am Explain to you all the possible methods here.

Without wasting your time, Let’s start This Article.

How does the double exclamation (!!) work in javascript ?

  1. How does the double exclamation (!!) work in javascript ?

    does the double exclamation (!!) work in javascript In JavaScript, the values falsenullundefined0-0NaN, and '' (empty string) are “falsy” values. All other values are “truthy.”(1):7.1.2 Here's a truth table of ! and !! applied to various values:

  2. does the double exclamation (!!) work in javascript

    does the double exclamation (!!) work in javascript In JavaScript, the values falsenullundefined0-0NaN, and '' (empty string) are “falsy” values. All other values are “truthy.”(1):7.1.2 Here's a truth table of ! and !! applied to various values:

Method 1

! is the logical negation or “not” operator. !! is ! twice. It’s a way of casting a “truthy” or “falsy” value to true or false, respectively. Given a boolean, ! will negate the value, i.e. !true yields false and vice versa. Given something other than a boolean, the value will first be converted to a boolean and then negated. For example, !undefined will first convert undefined to false and then negate it, yielding true. Applying a second ! operator (!!undefined) yields false, so in effect !!undefined converts undefined to false.

In JavaScript, the values falsenullundefined0-0NaN, and '' (empty string) are “falsy” values. All other values are “truthy.”(1):7.1.2 Here’s a truth table of ! and !! applied to various values:

Summery

It’s all About this article. Hope all method helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you? Thank You.

Leave a Comment