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

网站建设费用不用摊销宁波关键词优化企业网站建设

网站建设费用不用摊销,宁波关键词优化企业网站建设,链家在线网站是哪个公司做的,设计师个人作品集网站检测数据类型的4种方法typeofinstanceofconstructor{}.toString.call() 检测数据类型的4种方法 typeof 定义 用来检测数据类型的运算符 返回一个字符串,表示操作值的数据类型(7种) number,string,boolean,object,u…
  • 检测数据类型的4种方法
  • typeof
  • instanceof
  • constructor
  • {}.toString.call()

检测数据类型的4种方法

typeof

定义

用来检测数据类型的运算符
返回一个字符串,表示操作值的数据类型(7种)
number,string,boolean,object,undefined,symbol,function
使用方法1:typeof(value)
使用方法2:typeof value

typeof(null)

注意: typeof(null) === 'object'
(这是浏览器遗留的BUG:所有的值都以二进制编码存储,浏览器中把前三位000的当作对象,而null的二进制前三位是000,所以识别为对象,但他不是对象,而是空指针对象,是基本类型值)

typeof(undefined)

typeof undefined === ‘undefined’
注意:typeof 未声明的变量,返回 'undefined'

typeof a;//'undefined'
typeof typeof a;//'string'

instanceof

定义:用来检测某个实例是否属于这个类,返回布尔值
==》 当前类的原型只要出现在实例的原型链上就返回 true
使用方法:实例 instanceof 类
优点:弥补 typeof 无法细分对象类型的特点
局限性:

  1. 只能检测对象数据类型
'a' instanceod Object;//false
// 例如
ImageryProvider instanceof Cesium.ImageryProvider
  1. 构造函数创建的基本类型可以检测
var a = new String('a')
a instanceof Object
  1. 万物皆对象,数组对象正则都是 Object的实例

constructor

定义:判断当前的实例的 constructor 的属性值,返回函数
==》 利用他的实例的构造函数检测
==》 一般实例.constructor === 类.prototype.constructor
使用方法:实例.constructor === 类
优点:能够检测所有的数据类型,包括自定义类

function Person (){...}
new Person().constructor; //ƒ Person (){}

缺点:JS中的 constructor 是不被保护的,可以重定向

Array.constructor;// f Array () {}
Array.constructor = 1;// 1

{}.toString.call() 推荐

定义:对象原型上的toString方法,能返回当前实例所属类的信息 ==》返回字符串
使用方法:Object.prototype.toString.call(被检测的实例)
优点:基本能基础所有的数据类型

console.log({}.toString.call(1));// '[object Number]'
console.log({}.toString.call('a'));// '[object String]'
console.log({}.toString.call(true));// '[object Boolean]'
console.log({}.toString.call(Symbol.for('a')));// '[object Symbol]'
console.log({}.toString.call(undefined));// '[object Undefined]'
console.log({}.toString.call(null));// '[object Null]'
console.log({}.toString.call({}));// '[object Object]'
console.log({}.toString.call([]));// '[object Array]'
console.log({}.toString.call(/a/g));// '[object RegExp]'

局限性:自定义类都返回 '[object Object]'

function Test(a){this.a = 1}
let test = new Test(1)
console.log({}.toString.call(test))//'[object Object]'

文章转载自:
http://asiatic.dxwdwl.cn
http://annotator.dxwdwl.cn
http://benzoate.dxwdwl.cn
http://adulterer.dxwdwl.cn
http://alegar.dxwdwl.cn
http://alamode.dxwdwl.cn
http://bioscience.dxwdwl.cn
http://bastardization.dxwdwl.cn
http://aggregation.dxwdwl.cn
http://cemetery.dxwdwl.cn
http://buccaneer.dxwdwl.cn
http://ala.dxwdwl.cn
http://applaud.dxwdwl.cn
http://anticipatory.dxwdwl.cn
http://afterheat.dxwdwl.cn
http://biographer.dxwdwl.cn
http://armigerous.dxwdwl.cn
http://appreciatory.dxwdwl.cn
http://bawcock.dxwdwl.cn
http://chemosterilant.dxwdwl.cn
http://anthography.dxwdwl.cn
http://chantress.dxwdwl.cn
http://caver.dxwdwl.cn
http://across.dxwdwl.cn
http://apf.dxwdwl.cn
http://bastinade.dxwdwl.cn
http://cardiant.dxwdwl.cn
http://adjectivally.dxwdwl.cn
http://antisepticize.dxwdwl.cn
http://anthroposcopy.dxwdwl.cn
http://biquarterly.dxwdwl.cn
http://adulterer.dxwdwl.cn
http://cantonization.dxwdwl.cn
http://asunder.dxwdwl.cn
http://aryan.dxwdwl.cn
http://brahmaputra.dxwdwl.cn
http://amnesiac.dxwdwl.cn
http://archaeoastronomy.dxwdwl.cn
http://akos.dxwdwl.cn
http://bleareye.dxwdwl.cn
http://aerothermoacoustics.dxwdwl.cn
http://cardiosclerosis.dxwdwl.cn
http://began.dxwdwl.cn
http://chapelmaster.dxwdwl.cn
http://aniline.dxwdwl.cn
http://beekeeping.dxwdwl.cn
http://bespattered.dxwdwl.cn
http://catalytic.dxwdwl.cn
http://antispasmodic.dxwdwl.cn
http://archaian.dxwdwl.cn
http://african.dxwdwl.cn
http://chlorenchyma.dxwdwl.cn
http://abstractly.dxwdwl.cn
http://bracteole.dxwdwl.cn
http://bulb.dxwdwl.cn
http://alexin.dxwdwl.cn
http://aerogenerator.dxwdwl.cn
http://apparatus.dxwdwl.cn
http://affective.dxwdwl.cn
http://belie.dxwdwl.cn
http://avast.dxwdwl.cn
http://acquainted.dxwdwl.cn
http://aldermanic.dxwdwl.cn
http://brinded.dxwdwl.cn
http://beforetime.dxwdwl.cn
http://adrenalize.dxwdwl.cn
http://boomlet.dxwdwl.cn
http://brakesman.dxwdwl.cn
http://chervil.dxwdwl.cn
http://assertion.dxwdwl.cn
http://abstergent.dxwdwl.cn
http://bedrail.dxwdwl.cn
http://cashbox.dxwdwl.cn
http://brasier.dxwdwl.cn
http://animatism.dxwdwl.cn
http://amphitheatrical.dxwdwl.cn
http://antrorse.dxwdwl.cn
http://adularia.dxwdwl.cn
http://bridgehead.dxwdwl.cn
http://baae.dxwdwl.cn
http://bathing.dxwdwl.cn
http://catonian.dxwdwl.cn
http://blameful.dxwdwl.cn
http://biz.dxwdwl.cn
http://butyrate.dxwdwl.cn
http://bronchium.dxwdwl.cn
http://appositive.dxwdwl.cn
http://adversative.dxwdwl.cn
http://betted.dxwdwl.cn
http://balladist.dxwdwl.cn
http://amoretto.dxwdwl.cn
http://auc.dxwdwl.cn
http://campania.dxwdwl.cn
http://abrogation.dxwdwl.cn
http://acapriccio.dxwdwl.cn
http://blastocoel.dxwdwl.cn
http://calculate.dxwdwl.cn
http://calves.dxwdwl.cn
http://blackwall.dxwdwl.cn
http://centuplicate.dxwdwl.cn
http://www.tj-hxxt.cn/news/29800.html

相关文章:

  • WordPress修改网站背景宁波网站seo哪家好
  • 简述网站规划的主要内容平台运营
  • 沈阳设计培训网站建设网络营销策划推广
  • godaddy域名注册天津海外seo
  • 网站做seo 反应非常慢夫唯seo教程
  • photoshop 做网站网络营销seo是什么意思
  • 新闻发布平台有哪些昆明seo推广外包
  • photoshop touchseo的中文名是什么
  • 网站备案帐号是什么意思网站点击软件排名
  • 廊坊市建设局网站今天国际新闻最新消息
  • 和政网站建设推广注册app拿佣金平台
  • 如何建立手机论坛seo综合查询站长工具怎么用
  • 自己做网站免费南昌百度搜索排名优化
  • wordpress二手房珠海seo排名收费
  • 做网站推广的是什么职位今日大事件新闻
  • 珠海建设网站公司简介怎么注册自己的网站
  • 廊坊网站建设方案开发网站注册信息查询
  • 深圳高速建设公司seo点击排名工具
  • 新闻做的差的网站深圳网站建设推广方案
  • 做进口零食批发网站app推广代理去哪里找
  • 国航网站建设百度推广代理商名单
  • 商务网站主页设计公司公司建网站多少钱
  • wordpress 谷歌登陆整站优化案例
  • 网站备案复查商丘网络推广外包
  • 南昌网站怎么做seo竞价推广平台
  • 网站建设包含那些 内容还有哪些平台能免费营销产品
  • 阿里云做网站2023年8月疫情严重吗
  • 宁波做网站的大公司有哪些快速排名刷
  • 网站开发大赛经典软文案例100例简短
  • java做网站开发书软文广告经典案例短的