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

淘宝网的网站设计方案重庆网站怎么做出来的

淘宝网的网站设计方案,重庆网站怎么做出来的,电脑学校,oa系统运维typeof 基于数据类型的值(二进制)进行检测返回结果为字符串typeof NaN结果为numbertypeof null结果为Object.对象存储以000开头#xff0c;而null也是如此。typeof不能细分对象#xff0c;结果都是Objecttypeof function(){}结果为function instanceof 检测某个构造函数是…typeof 基于数据类型的值(二进制)进行检测返回结果为字符串typeof NaN结果为numbertypeof null结果为Object.对象存储以000开头而null也是如此。typeof不能细分对象结果都是Objecttypeof function(){}结果为function instanceof 检测某个构造函数是否出现在某实例的原型链上返回结果为boolean值[] instanceof Array为true, [] instanceof Object为true。原型可手动修改因此检测结果也会被篡改。不能检测基本数据类型。1 instanceof Number为false constructor 检测某个函数是否是某实例的构造函数返回结果为boolean值可以检测基本数据类型constructor可手动修改因此检测结果也会被篡改。 Object.prototype.toString.call() 返回当前实例所属类的信息 Object.prototype.toString.call(1) // [object Number] Object.prototype.toString.call(1) // [object String] Object.prototype.toString.call(true) // [object Boolean] Object.prototype.toString.call(null) // [object Null] Object.prototype.toString.call(undefined) // [object Undefined] Object.prototype.toString.call(Symbol(1)) // [object Symbol] Object.prototype.toString.call(/^/) // [object RegExp] Object.prototype.toString.call(new Date) // [object Date] Object.prototype.toString.call([]) // [object Array] Object.prototype.toString.call({}) // [object Object] Object.prototype.toString.call((){}) // [object Function] Object.prototype.toString.call(1n) // [object BigInt] Object.prototype.toString.call(new Error()) // [object Error]最佳实践 typeof 可以检测基本数据类型的值(除 Null 以外)其他的类型可以用Object.prototype.toString.call() 封装数据类型检测的方法 目标能够对Number,String,Boolean,Null,Undefined,Symbol,RegExp,Date,Array,Object,Function,Error,BigInt全部类型值进行细分检测。 类型检测函数 function toType(obj){const classType {};[Number,String,Boolean,Null,Undefined,Symbol,RegExp,Date,Array,Object,Function,Error,BigInt].forEach(name {classType[[object ${name}]] name.toLowerCase()});function _toType(obj){if(obj null) return obj return typeof obj object || typeof obj function ? classType[toString.call(obj)] || object : typeof obj}return _toType(obj) }进行测试 // 测试 [1,1,true,null,undefined,Symbol(1),/^/,new Date(),[],{},(){},new Error(),100n].forEach(obj {console.log(toType(obj)) })/* number string boolean null undefined symbol regexp date array object function error bigint */建立映射表进行比对 const map [[1,number],[1,string],[true,boolean],[null,null],[undefined,undefined],[Symbol(1),symbol],[/^/,regexp],[new Date(),date],[[],array],[{},object],[(){},function],[new Error(),error],[100n,bigint] ]for (const tuple of map) {console.log(toType(tuple[0]) tuple[1]) }/* true true true true true true true true true true true true true */本文github地址:JavaScript_Everything 大前端知识体系与面试宝典从前端到后端全栈工程师成为六边形战士
http://www.pierceye.com/news/590071/

相关文章:

  • 中国做网站东台做网站公司
  • 建设数据库网站需要哪些设备wordpress多功能主题 cosy
  • 苏州市郭巷建设局网站一家专门做鞋子的网站
  • 光明网站建设网站建设成果
  • 商业网站建设举例宝塔做两个网站6
  • 网站优化排名分享隐迅推前端开发入门培训
  • 曲周县建设局网站东莞保安公司电话
  • 合肥商城网站建设多少钱wordpress页面代码怎么改
  • 前期做网站宣传费用怎样做账企业网站建设的劣势
  • 网站建设企业哪家好做网站三大主流框架
  • 网站托管服务方案珲春建设局网站
  • 开发网站公司收入重庆多功能网站建设
  • 河北手机网站建设上海网站seo招聘
  • 厦门市建设局思明建设分局官方网站在谷歌上做外贸网站有用吗
  • 网站开发手机自适应直接在原备案号下增加新网站
  • 公司网站建设安全的风险网络工程师app
  • 网站app封装怎么做电商网页
  • 网站文章做排名wordpress菜单文本
  • 建站哪家好社区个人网站模板 免费
  • 东西湖区建设局网站如何生成网址链接
  • wordpress商城视频教程苏州推广关键词优化
  • 网站游戏正规网站建设安卓系统软件开发培训机构
  • 关于网站集约化建设的讲话周口seo公司
  • 长沙做网站的公司哪家最好服务公司取名
  • 网站缩略图制作宁波商城网站建设
  • 公司网站公众号维护怎么做湖南网站建设
  • 商务网站建设实训结论装饰装修工程
  • dw做网站简单吗网络科技建设网站
  • 天台建设局网站wordpress编辑器没有16px
  • 携程网站建设计划管理与进度控制志鸿优化设计电子版