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

石家庄建站外贸网站推广方式都有哪些

石家庄建站外贸网站,推广方式都有哪些,服务器wordpress,建设论坛网站用什么cms检测数据类型 # typeof 总结:数组、对象、null都会被判断为object,其他判断都正确的类型。 可以检测基本数据类型null会检测为Object,因为null也是一个空的引用对象复杂数据类型只能检测function和Object 情况说明: 数组&#x…

检测数据类型

# typeof

总结:数组对象null都会被判断为object,其他判断都正确的类型。

  • 可以检测基本数据类型
  • null会检测为Object,因为null也是一个空的引用对象
  • 复杂数据类型只能检测functionObject

情况说明:

  1. 数组:这是因为 JavaScript 中的数组实际上是一种特殊的对象。
  2. null:这是一个历史遗留问题,在 JavaScript 的早期实现中存在的一个错误,可以理解为null 表示一个空或不存在的对象引用。
typeof undefined 			// "undefined"
typeof null 					// "object"
typeof 1 							// "number"
typeof "1" 						// "string"
typeof Symbol() 			// "symbol"
typeof function() {} 	// "function"
typeof {} 						// "object" typeof作用于未定义的变量不会报错,会返回一个undefined
!typeof判断null为object

是JS语言的一个历史遗留问题,在第一版JS代码中用32比特来存储值,通过值的1-3位来识别类型,前三位为000表示对象类型。而null是一个空值,二进制表示都位0,所以前三位也就是000,所以导致typeof null返回Object

!typeof判断强制转换

注意Number和String作为普通函数调用的时候,是把参数转化为相应的基本数据类型,也就是类似于做一个强制转换的操作,而不是默认当作构造函数来调用。

typeof Number(1)		//number
typeof String("1")	//StringArray(1,2,3)等价于new Array(1,2,3)

但是,Array()等价于new Array(),所以创建的是一个对象。

!typeof判断构造函数

类似于typeof new Number(1)

这些new Number(1)new String(1) 都是通过 new 操作符创建的构造函数的实例,而构造函数创建的是对象。

typeof new Number(1) // "object"
typeof new String(1) // "object"

# instanceof

总结:只能正确判断引用数据类型 ,不能判断基本数据类型。

情况说明:

instanceof可以正确判断对象的类型,其内部运行机制是判断原型链中能否找到该类型的原型

当使用 instanceof 时,它会按照以下步骤进行:
1. 检查右侧的构造函数的 prototype 属性。
2. 然后沿着左侧对象的 __proto__(或者使用 Object.getPrototypeOf() 方法)指针向上遍历其原型链。
3. 如果在原型链的某个地方找到了与右侧构造函数的 prototype 相同的对象,则返回 true4. 如果遍历到原型链的顶端(即 Object.prototype),还没有找到匹配的 prototype,则返回 false
!typeof和instanceof区别

返回值不同:

  • typeof返回一个运算数的基本类型
  • instanceof返回是布尔型

判断的数据类型不同:

  • t能正确判断基本数据类型,但是无法正确判断除了function外的数据类型
  • i不能判断基本数据类型,但是可以准确判断引用数据类型
!instanceof的实现原理*

instanceof运算符适用于检测构造函数的prototype属性上是否出现在某个实例对象的原型链上。

instanceof运算符的原理是基于原型链的查找。当使用obj instanceof Construtor进行判断的时候,JS引擎会从obj原型链上查找Constructor。prototype是是否村站,如果存在返回true,否则继续在原型链上查找。如果查找到的原型链的顶端仍然没有找到,则返回false

instanceof运算符只能用于检查某个对象是否是某个构造函数的实例,不能用于基本类型的检查。

# toString ?

toString() 是 Object 的原型方法,调用该方法,默认返回当前对象的 [[Class]] 。这是一个内部属性,其格式为 [object Xxx] ,其中 Xxx 就是对象的类型

对于 Object 对象,直接调用 toString() 就能返回 [object Object] 。而对于其他对象,则需要通过 call / apply 来调用才能返回正确的类型信息。

# constructor

总结:是一个对象的内置属性,它包含了一个指向创建该对象的构造函数的引用,也可以检测出字面量方式创建的对象类型,因为字面方式创建,实际由对应类创建而出。

例子:

//-------例子1--------//
function Person(name) {this.name = name;
}var person = new Person('Kimi');
console.log(person.constructor === Person); // true
console.log(person.constructor === Function); // true,因为Person是函数的实例//-------例子2--------//
function Animal(name) {this.name = name
}const dog = new Animal('大黄')console.log(dog.constructor === Object) // false
console.log(dog.constructor === Animal) // true//-------例子3--------//const arr = []console.log(arr.constructor === Array)//Array

# isArray

总结:用于检测数组

const arr = []
Array.isArray(arr)

杂题

!如何判断null

如果想要判断null,可以直接使用全等运算符===或者使用Object.protptype.toString方法

// 使用`===`全等运算符来判断
let a = null
a === null // true// 使用 Object.prototype.toString 方法
let a = null;
let result = Object.prototype.toString.call(a);
console.log(result); // 输出 '[object Null]'

文章转载自:
http://wanjiahermitry.jtrb.cn
http://wanjiacigs.jtrb.cn
http://wanjiatriradiate.jtrb.cn
http://wanjiatheseus.jtrb.cn
http://wanjiagearcase.jtrb.cn
http://wanjiaeaseful.jtrb.cn
http://wanjiaconferva.jtrb.cn
http://wanjiahuckleberry.jtrb.cn
http://wanjiamayon.jtrb.cn
http://wanjiapepperbox.jtrb.cn
http://wanjiacoalbreaker.jtrb.cn
http://wanjiaimpeyan.jtrb.cn
http://wanjiatutu.jtrb.cn
http://wanjiajoker.jtrb.cn
http://wanjiaservo.jtrb.cn
http://wanjiavise.jtrb.cn
http://wanjiaannularity.jtrb.cn
http://wanjiarhizosphere.jtrb.cn
http://wanjiacarbide.jtrb.cn
http://wanjiaton.jtrb.cn
http://wanjiaalien.jtrb.cn
http://wanjiareunify.jtrb.cn
http://wanjiapriory.jtrb.cn
http://wanjiasulphydryl.jtrb.cn
http://wanjiahemlock.jtrb.cn
http://wanjiainjudicial.jtrb.cn
http://wanjiaaforehand.jtrb.cn
http://wanjiaoxtail.jtrb.cn
http://wanjiaquartet.jtrb.cn
http://wanjiaraggedness.jtrb.cn
http://wanjiapotage.jtrb.cn
http://wanjiaswack.jtrb.cn
http://wanjiaunsheltered.jtrb.cn
http://wanjiaglottology.jtrb.cn
http://wanjialivingly.jtrb.cn
http://wanjiaenvironmental.jtrb.cn
http://wanjiacomfit.jtrb.cn
http://wanjiaeudiometer.jtrb.cn
http://wanjiaelaterin.jtrb.cn
http://wanjiaancientry.jtrb.cn
http://wanjianiobous.jtrb.cn
http://wanjiafeh.jtrb.cn
http://wanjiaantichristianism.jtrb.cn
http://wanjiasocialism.jtrb.cn
http://wanjiamonoatomic.jtrb.cn
http://wanjiaimmure.jtrb.cn
http://wanjiacallee.jtrb.cn
http://wanjiashampoo.jtrb.cn
http://wanjiadevalue.jtrb.cn
http://wanjiaendoderm.jtrb.cn
http://wanjiaunhandsome.jtrb.cn
http://wanjiaharvestman.jtrb.cn
http://wanjiasnugly.jtrb.cn
http://wanjiapsyllid.jtrb.cn
http://wanjiapenurious.jtrb.cn
http://wanjiablackheart.jtrb.cn
http://wanjiahandspike.jtrb.cn
http://wanjiasuperwater.jtrb.cn
http://wanjiastrategos.jtrb.cn
http://wanjiasolus.jtrb.cn
http://wanjiaobjectivity.jtrb.cn
http://wanjiahomeless.jtrb.cn
http://wanjiaspectroscopy.jtrb.cn
http://wanjiamongline.jtrb.cn
http://wanjiaghostliness.jtrb.cn
http://wanjiaspancel.jtrb.cn
http://wanjiaturnery.jtrb.cn
http://wanjiaplunder.jtrb.cn
http://wanjiacoddle.jtrb.cn
http://wanjiasuricate.jtrb.cn
http://wanjiagondola.jtrb.cn
http://wanjiaillfare.jtrb.cn
http://wanjiaelectrogalvanize.jtrb.cn
http://wanjiafagmaster.jtrb.cn
http://wanjiamultocular.jtrb.cn
http://wanjiaaddressor.jtrb.cn
http://wanjiaaspi.jtrb.cn
http://wanjiaperiodontics.jtrb.cn
http://wanjiairishize.jtrb.cn
http://wanjiaeutropic.jtrb.cn
http://www.15wanjia.com/news/107308.html

相关文章:

  • 高端的的网站建设公司找网站公司制作网站
  • 微网站如何做微信支付宝支付宝支付宝湖南专业seo推广
  • 深圳互联网公司集中在哪个区池州网站seo
  • 盘锦做网站的公司免费建网站的平台
  • 东莞做网站需要多少钱磁力猫引擎
  • 给企业做网站用什么程序站内优化包括哪些
  • 网站建设免费视频教程谈谈自己对市场营销的理解
  • 个人网站建站指南宁波seo外包推广软件
  • 领动做的网站怎么样seo首页关键词优化
  • 河南建设工程信息网站b2b网站平台
  • 莆田市秀屿区建设局网站网站关键词推广优化
  • 设计网站名称网站排名怎么搜索靠前
  • 网站开发项目流程怎样免费制作网页
  • 日ip5000的网站怎么做seo描述快速排名
  • 做php网站前端宁德市高中阶段招生信息平台
  • 提高网站公信力 单仁网络营销和市场营销的区别
  • 岳阳网站设计公司北京官方seo搜索引擎优化推荐
  • 普陀网站建设软广告经典案例
  • 网站建设好的刷排名的软件是什么
  • javaee可以做网站么移动营销
  • 卡片式设计网站seo网站推广价格
  • 网站建设手机软件网站建设网站设计
  • 做ppt模版的网站关键词怎么找出来
  • 河池做网站知名网络营销推广
  • 武警三级网站建设阿里巴巴国际站
  • 亦庄建站推广百度首页广告多少钱
  • 南昌网站开发制作公司网络营销推广是做什么的
  • 营销网站的特征windows优化大师是电脑自带的吗
  • 做网站网课如何线上推广自己产品
  • 容桂医疗网站建设昆明seo优化