1min takes you to understand JS! and!!

Written in the front:

I am "Boiled Sheep Sheep_", my nickname comes from the abbreviation fyy of my name. The blog I worked hard to run before was accidentally cancelled due to a handicap, and now I operate this account.
I am a small dish, and I am working hard in the direction of a full-stack engineer. The article may not be very productive and basic, but every article I write is summarized carefully, please do not spray.
If you are interested in programming, please follow my dynamics and study together.
Thank you every reader!

!

! Represents the variable to be converted to boolean type, for example:

!null = true
!undefined = true
!'' = true
!'abc' = false

!!

!! is an operation that forcibly converts an expression into a boolean type. If the result of the operation is true or false, what value the expression is, the result is the corresponding boolean value, and no more negation. Rather than negate and then negate, negative means positive. Examples are as follows:

if(a != null && typeof(a) != undefined && a != ''){
    
    
	//a有内容执行的内容
}

In fact, we can use!! instead of the troublesome writing above.

if(!!a){
    
    
	//a有内容执行的内容
}

Guess you like

Origin blog.csdn.net/weixin_42653522/article/details/108203645