Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

double bang js

We use the double bang operator (!!) to check if a value is `truthy` or `falsy`.
That means to check if a value is considered `true` or `false` by JavaScript.

We use it when we need a boolean value according to a non-boolean value,
for example if we need the value `false` if a string is empty, `true` otherwise.
                                 
str = "Double bang operator"; // not empty strings are considered true by JS
console.log(str == true); // false
console.log(!!str); // true
str = ""; // empty strings are considered false by JS
console.log(str == false); // true
console.log(!!str); // false

Truthy values :
 - Objects : {}   // even empty objects
 - Arrays : []   // even empty Arrays
 - Not empty strings : "Anything"
 - Numbers other than 0 : 3.14
 - Dates : new Date()
Falsy values :
 - Empty strings : ""
 - 0
 - null
 - undefined
 - NaN
Comment

double bang js

The double bang is said as (!!True) or (!(True)) means that the outcome will be
the opposite of what its supposed to be.


note: I am only 50% sure if its true its just something I read on a website.
Comment

PREVIOUS NEXT
Code Example
Javascript :: js upload file size limit 
Javascript :: min in array 
Javascript :: javascript casting objects 
Javascript :: where to create service angularor nodejs 
Javascript :: sort array with negative numbers 
Javascript :: add array type to sequelize migration 
Javascript :: Bracket Notation Example 
Javascript :: javascript async await returns undefined 
Javascript :: row append and calculation in jquery datatable 
Javascript :: javascript program problems 
Javascript :: filter 2d array javascript 
Javascript :: rxjs coding example 
Javascript :: JavaScript Change the Elements of an Array 
Javascript :: pass ? url data 
Javascript :: event listener js keydown not working 
Javascript :: using settings_data.json shopify 
Javascript :: combine all ts files into one js 
Javascript :: esx global error 
Javascript :: double click sur image change javascript 
Javascript :: react native textinput disable keyboard 
Python :: check if tensorflow gpu is installed 
Python :: number table python 
Python :: python b to string 
Python :: how to open any program on python 
Python :: where to import messages in django 
Python :: python beep windows 
Python :: python if main 
Python :: add text toimage cv2 
Python :: how to make a hidden file in python 
Python :: incognito mode in selenium 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =