当前位置: 首页 > news >正文

现在做网站有前途吗广告策划书的内容

现在做网站有前途吗,广告策划书的内容,手机制作软件下载,相城seo网站优化软件js判断是否为null#xff0c;undefined#xff0c;NaN#xff0c;空串或者空对象 这里写目录标题 js判断是否为null#xff0c;undefined#xff0c;NaN#xff0c;空串或者空对象特殊值nullundefinedNaN空字符串#xff08;#xff09;空对象#xff08;…js判断是否为nullundefinedNaN空串或者空对象 这里写目录标题 js判断是否为nullundefinedNaN空串或者空对象特殊值nullundefinedNaN空字符串空对象{} typeof函数判断undefined判断nullundefined和null 和 的理解 判断NaN判断空字符串判断对象为空使用JSON.stringify()使用es6的方法Object.keys()for in 循环判断使用Object对象的getOwnPropertyNames方法 判断空数组 特殊值 null 是一个特殊的值表示一个空或者不存在的对象引用表示一个变量被人为的设置为空对象不是原始状态。 undefined 当一个变量被声明但没有赋值时它的默认值是 undefined。此外当访问不存在的对象属性或数组元素时结果也是 undefined。 NaN Not a Number是一个特殊的值表示在执行数学运算时结果不是一个合法的数字。NaN 属于 Number 类型它与任何值包括 NaN 本身都不相等。 出现NaN的情况 数学运算中的无效操作例如0 / 0 或 Math.sqrt(-1)将非数字的值强制转换为数字时例如parseInt(abc) 或 Number(xyz) 空字符串“” 一个空字符串是一个长度为 0 的字符串。它不是 null 或 undefined而是一个完全有效的字符串只是它没有内容。 空对象{} 空对象是一个没有任何属性的对象。它不是 null、undefined 或空字符串而是一个有效的 JavaScript 对象。 typeof函数 基本类型String、Number、Boolean、Symbol、Undefined、Null 引用类型Objectobject、array、function typeof // string typeof Bill Gates // string typeof 0 // number typeof 3.14 // number typeof false // boolean typeof true // boolean typeof Symbol() // symbol typeof Symbol(mySymbol); // symbol typeof undefined // undefined typeof null // object typeof {name:Bill, age:62} // object typeof [0, 1, 2] // object typeof function(){} // function typeof ((){}) // function typeof testnull // function testnull是函数名判断undefined let a undefined; if (typeof (a) undefined || a undefined) {console.log(undefined); }判断null 需要注意的是 typeof(null) object let b null; console.log(typeof (b));if (b null) {console.log(null1); } // !key typeof(key)!undefined 过滤完之后只剩 null 和 0 了再用一个 key!0 就可以把 0 过滤掉了 if (!b typeof (b) ! undefined b ! 0) {console.log(null2); }undefined和null if(a null) { // 等同于 a undefined || a nullconsole.log(为null); }undefined 和 null 用 比较是相等的 null 的类型是 objectundefined 的类型是 undefined 是先把左右两边转化为相同的类型再进行区分 和 的理解 严格相等会先比较类型再比较值 宽松相等是先把左右两边转化为相同的类型再进行区分仅要求值相等而不要求类型 true 转化为整数后是 1false 转化为整数后是 0 https://cloud.tencent.com/developer/article/1703891 https://blog.csdn.net/qq_42533666/article/details/129190944 判断NaN NaN具有非自反的特点所谓的非自反就是说NaN 与谁都不相等包括它本身但在 NaN ! NaN 下会返回true可以根据这个特性判断 let num NaN; let num2 0/0;if (typeof (num) number isNaN(num)) {console.log(num is NaN1); } if (num2 ! num2) {console.log(num is NaN2); }https://blog.csdn.net/Lu5957/article/details/122609879 https://blog.csdn.net/qq_43563538/article/details/103815482 https://www.cnblogs.com/k1023/p/11851943.html 判断空字符串 直接将其与空字符串比较或者调用 trim() 函数去掉前后的空格然后判断字符串的长度 判断字符串为空空格算空 let str ;if (str || str.trim().length 0){console.log(empty str 1); }if (typeof str string str.length 0) {console.log(not empty str); }判断字符串不为空空格不算空 if (typeof s string s.length 0) {console.log(not empty str); }https://blog.csdn.net/K346K346/article/details/113182838 判断对象为空 使用JSON.stringify() 将 JavaScript 值转换为 JSON 字符串再判断该字符串是否为{} let data {}; if (JSON.stringify(data) {}) {console.log(empty obj 1); }使用es6的方法Object.keys() if (Object.keys(data).length 0) {console.log(empty obj 2); }for in 循环判断 通过 for…in 语句遍历变量的属性 if (judge(data)) {console.log(empty obj 3); } function judge(data) {for (let key in data) {return false;}return true; }使用Object对象的getOwnPropertyNames方法 使用Object对象的getOwnPropertyNames方法获取到对象中的属性名存到一个数组中返回数组对象通过判断数组的length来判断此对象是否为空 if (Object.getOwnPropertyNames(data).length 0) {console.log(empty obj 4); }https://www.jb51.net/article/209387.htm https://www.cnblogs.com/shanhubei/p/16969190.html https://blog.csdn.net/qq_38709383/article/details/123224833 判断空数组 首先判断变量是否为数组然后通过 length 属性确定 let arr []; if (arr.length 0) {console.log(empty arr 1); }if (arr instanceof Array !arr.length) {console.log(empty arr 2); }if (Array.isArray(arr) !arr.length) {console.log(empty arr 3); }
http://www.w-s-a.com/news/679830/

相关文章:

  • 北京网站建设公司服务哪家好wap是什么意思?
  • 怎么看公司网站做的好不好哦wordpress页面目录下
  • 做装修业务呢有多少网站平台搭建是什么
  • 潍坊优化网站排名淘宝做网站被骗
  • 建设专业网站的利弊免费logo设计生成器下载
  • 怎么在备案号添加网站网页设计动画网站
  • 网站开发 只要wordpress滑动注册
  • 跨境电商运营主要做什么静态网站如何做优化
  • 南充网站建设网站网站备案安全责任书是谁盖章
  • 怎么将网站设置为首页网站子目录怎么做
  • 做网站交互wordpress信息导出
  • 如何自己做企业网站做外贸登录国外网站
  • 郑州炫彩网站建设网站集约化建设调研报告
  • 2016年两学一做教育网站优良的定制网站建设制作商
  • 自己做网站需要哪些流程网站建设服务费如何做会计分录
  • 莆田建站培训用手机制作游戏的app软件
  • 中山建网站找哪家wordpress采集图片插件
  • 网站首页做后台链接有什么好用的模拟建站软件
  • 宁波有没有开发网站的公司网站上线除了备案还需要什么
  • 网站备案授权wordpress默认主体设置
  • 厦门微信网站广州推广策划公司
  • 集团公司网站开发asp网站怎么运行
  • 广州短视频网站开发东莞市建设信息网
  • 建设网站如果赚钱电脑可以做服务器部署网站吗
  • 网站建设的编程专门做面包和蛋糕的网站
  • 档案网站建设比较分析南京建站公司
  • 哪个网站可以做店招傻瓜式wordpress
  • 网站开发项目经理职责青岛模版网站建设
  • 企业建站哪个好网站建设所用程序
  • 网站建设seo视频定制图片软件