Is there a standard function to check for null, undefined, or blank variables in JavaScript?

前端 未结 30 3693
眼角桃花
眼角桃花 2020-11-21 23:37

Is there a universal JavaScript function that checks that a variable has a value and ensures that it\'s not undefined or null? I\'ve got this code,

30条回答
  •  梦如初夏
    2020-11-22 00:16

    It may be usefull.

    All values in array represent what you want to be (null, undefined or another things) and you search what you want in it.

    var variablesWhatILookFor = [null, undefined, ''];
    variablesWhatILookFor.indexOf(document.DocumentNumberLabel) > -1
    

提交回复
热议问题