Typescript's ~~ and double exclamation mark symbols are used

(Do not use "!" in the title)

Use of "~~" symbol

1. For values ​​of type number, ~~ is the rounding function
const num: number = 3.14;
const roundedNum: number = ~~num; // 3
2. For values ​​of type boolean, ~ ~ true is still true, false is still false
Insert image description here

Use of "!!" symbol

!!Mainly used for type judgment
if(!!dupha){ //dupha variable has a value, (not Null or undefined or "" or 0) }

Guess you like

Origin blog.csdn.net/mingketao/article/details/132628524