Does the double-exclamation (!!) trick always produce true or false in JavaScript?

c00000fd

Pardon me asking (I'm coming from the world of C/C++)

I'm curious if the following line will always set bResult to be either true or false in JavaScript?

var bResult = !!someVariable;
kornieff

Shorthand used for converting anything to boolean type, same as

var bResult = Boolean(someVariable);

https://stackoverflow.com/a/264037/3094153

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Why does my condition always evaluate as true?

분류에서Dev

What does True (.T.) and False (.F.) mean

분류에서Dev

Javascript true or false test won't output anything

분류에서Dev

중첩 (조건)? JavaScript의 true : false 문

분류에서Dev

Javascript If else returns either only TRUE or only FALSE

분류에서Dev

How to return(true/false) in ternary operators in jQuery/Javascript?

분류에서Dev

getCheckedItemPositions always return false

분류에서Dev

Nullable Decimal If Is Always True

분류에서Dev

PHP - Does 1 vs true, 0 vs false or verbosity of variable names affect performance?

분류에서Dev

IPython notebook does not produce output

분류에서Dev

Boolean Function Always Return False

분류에서Dev

Javascript 부울 true는 false로 바뀌고 false는 true로 바뀌지 않습니다.

분류에서Dev

Trying to set hidden input's value to toggle between True and False in JavaScript

분류에서Dev

What does exclamation mark mean inside Intern's define?

분류에서Dev

Why does Scala ignore exclamation points in command line arguments?

분류에서Dev

What does an exclamation mark mean in the Windows 8.1 Mail App?

분류에서Dev

Why is this PHP if condition always true?

분류에서Dev

False / True 열 상수

분류에서Dev

Return only true or false (PHP)

분류에서Dev

None, False, True 확인

분류에서Dev

Does this code produce 2 NSTimers instead of 1?

분류에서Dev

Why does redirecting output to a file produce a table?

분류에서Dev

부울 true를 javascript에서 false와 같게 만들 수 있습니까?

분류에서Dev

Javascript에서 true와 false가 문자열이 될 수있는 이유

분류에서Dev

Jasmine date expect always returning false

분류에서Dev

Cakephp 2.5.2 Auth always returns false

분류에서Dev

Always return false when i authenticate an user

분류에서Dev

false && (false)? false : true가 true를 반환하는 이유

분류에서Dev

AHK if statment with variables not working always true

Related 관련 기사

  1. 1

    Why does my condition always evaluate as true?

  2. 2

    What does True (.T.) and False (.F.) mean

  3. 3

    Javascript true or false test won't output anything

  4. 4

    중첩 (조건)? JavaScript의 true : false 문

  5. 5

    Javascript If else returns either only TRUE or only FALSE

  6. 6

    How to return(true/false) in ternary operators in jQuery/Javascript?

  7. 7

    getCheckedItemPositions always return false

  8. 8

    Nullable Decimal If Is Always True

  9. 9

    PHP - Does 1 vs true, 0 vs false or verbosity of variable names affect performance?

  10. 10

    IPython notebook does not produce output

  11. 11

    Boolean Function Always Return False

  12. 12

    Javascript 부울 true는 false로 바뀌고 false는 true로 바뀌지 않습니다.

  13. 13

    Trying to set hidden input's value to toggle between True and False in JavaScript

  14. 14

    What does exclamation mark mean inside Intern's define?

  15. 15

    Why does Scala ignore exclamation points in command line arguments?

  16. 16

    What does an exclamation mark mean in the Windows 8.1 Mail App?

  17. 17

    Why is this PHP if condition always true?

  18. 18

    False / True 열 상수

  19. 19

    Return only true or false (PHP)

  20. 20

    None, False, True 확인

  21. 21

    Does this code produce 2 NSTimers instead of 1?

  22. 22

    Why does redirecting output to a file produce a table?

  23. 23

    부울 true를 javascript에서 false와 같게 만들 수 있습니까?

  24. 24

    Javascript에서 true와 false가 문자열이 될 수있는 이유

  25. 25

    Jasmine date expect always returning false

  26. 26

    Cakephp 2.5.2 Auth always returns false

  27. 27

    Always return false when i authenticate an user

  28. 28

    false && (false)? false : true가 true를 반환하는 이유

  29. 29

    AHK if statment with variables not working always true

뜨겁다태그

보관