Home  >  Article  >  Web Front-end  >  The role of!! in js

The role of!! in js

大家讲道理
大家讲道理Original
2016-11-07 16:51:201695browse

The function of !! in

js is:

!! is generally used to convert the following expressions into Boolean data (boolean)

=== indicates that all types are equal (just write an if to test it yourself) )

!== means you don’t want to wait and include the type (write an if the same way)

|| or means

!! Generally used to convert the following expression into Boolean data (boolean) because javascript It is a weakly typed language (variables do not have a fixed data type), so sometimes it is necessary to force conversion to the corresponding type,

Similar example: a=parseInt("1234") a="1234"+0 //Convert to number b =1234+"" //Convert to string c=someObject.toString() //Convert object to string. Type 1 and Type 4 are explicit conversions, and

2 and 3 are implicit conversions to Boolean type. The conversion, JavaScript convention is similar to c, the rules are: false, undefined, null, 0, "" is false, true, 1, "somestring", [Object] is true


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn