2015年12月28日 星期一

[javascript] not not (!!) 運算

!!false===false
!!true===true
!!0===false
!!parseInt("foo")===false// NaN is falsy
!!1===true
!!-1===true// -1 is truthy
!!""===false// empty string is falsy
!!"foo"===true// non-empty string is truthy
!!"false"===true// ...even if it contains a falsy value
!!window.foo===false// undefined is falsy
!!null===false// null is falsy
!!{}===true// an (empty) object is truthy
!![]===true// an (empty) array is truthy; PHP programmers beware!