Easiest way to check if string is null or empty

前端 未结 11 1218
南笙
南笙 2021-01-30 12:30

I\'ve got this code that checks for the empty or null string. It\'s working in testing.

eitherStringEmpty= (email, password) ->
  emailEmpty = not email? or          


        
11条回答
  •  鱼传尺愫
    2021-01-30 12:52

    unless email? and email
      console.log 'email is undefined, null or ""'
    

    First check if email is not undefined and not null with the existential operator, then if you know it exists the and email part will only return false if the email string is empty.

提交回复
热议问题