js判断是否为undefined

  if(typeof(bdsj1)=="undefined"){
            alert("没有定义");
            autoAddLine(formId);
        }

获取索要判断的 变量的类型 如果是undefined 进行字符串进行比较才可以。

js的typeof返回类型有如下 6 种:
number、string、boolean、object、function、undefined

猜你喜欢

转载自blog.csdn.net/ppwwp/article/details/88202614