Home > Web Front-end > JS Tutorial > body text

The role of!! in js

大家讲道理
Release: 2016-11-07 16:51:20
Original
1694 people have browsed it

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!