What does “!” operator mean in javascript when it is used with a non-boolean variable?

后端 未结 5 450
小鲜肉
小鲜肉 2020-12-03 10:53

While reading through javascript codes I\'ve been seeing the ! operator used for non boolean variables. Here is an example of code not used in.

         


        
5条回答
  •  甜味超标
    2020-12-03 11:46

    !object
    

    will return false when the object is undefined, equals to null or 0, true otherwise.

提交回复
热议问题