您现在的位置是:课程教程文章
js如何实现类型判断
2023-12-14 20:46课程教程文章 人已围观
-
原生js贪吃蛇游戏实战开发【渡一教育】
原生js贪吃蛇游戏实战开发【渡一教育】原生html,css,js实现贪吃蛇小游戏。此课程由开发经验丰富的陈学辉老师精心录... -
Web前端原生JS大型电商实战项目
Web前端原生JS大型电商实战项目... -
Web前端权威入门【2020新版】/JavaScript/JS项
Web前端权威入门【2020新版】/JavaScript/JS项小伙伴们, 免费领取高清精品视频、笔记、源码 ,加 小7老师QQ330496536 还可加... -
如何实现数据的高效沟通和传递
如何实现数据的高效沟通和传递欢迎学习 微软 V 课堂 公开课! 微软 V 课堂将不定期分享关于微软黑科技、Az...
1、判断引用类型和基本类型的类型是不同的,判断基本类型可以用typeof:
typeof1//'number' typeof'1'//'string' typeofundefined//'undefined' typeoftrue//'boolean' typeofSymbol()//'symbol' typeofnull//'object'
2、typeof对引用类型,除了函数返回function,其他都返回object。但我们开发中数组肯定是要返回array类型的,所以typeof对引用类型来说并不是很适用。判断引用类型一般用instanceof:
varobj={} vararr=[] varfun=()=>{} typeofobj//'object' typeofarr//'object' typeoffun//'function' objinstanceofObject//true arrinstanceofArray//true funinstanceofFunction//true
以上就是js类型判断的实现,希望对大家有所帮助。更多js学习指路:js教程
推荐操作环境:windows7系统、jquery3.2.1版本,DELL G3电脑。
课程教程:js如何实现类型判断下一篇:没有了