Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

js判断数据类型-js中if判断两个条件

1.分辨物件种类的方式:

//全能的种类分辨方式,能够分辨全部目标的种类const objectToString = Object.prototype.toString;const toTypeString = (value) => objectToString.call(value);//分辨是不是Arrayconst isArray = Array.isArray;//分辨是不是Mapconst isMap = (val) => toTypeString(val) === '[object Map]';//分辨是不是Setconst isSet = (val) => toTypeString(val) === '[object Set]';//分辨是不是Dateconst isDate = (val) => val instanceof Date;//分辨是不是Functionconst isFunction = (val) => typeof val === 'function';//分辨是不是Stringconst isString = (val) => typeof val === 'string';//分辨是不是Symbolconst isSymbol = (val) => typeof val === 'symbol';//分辨是不是是是非非空目标const isObject = (val) => val !== null && typeof val === 'object';//分辨是不是Promiseconst isPromise = (val) => {return isObject(val) && isFunction(val.then) && isFunction(val.catch);};//分辨是不是一般的Object目标const isPlainObject = (val) => toTypeString(val) === '[object Object]';//需注意:1.typeof 目标分辨方式:typeof null // "object";typeof undefined //"undefined"2.申明未取值的自变量的种类为undefined:let abc //undefined

2.分辨一个目标是不是有特性的方式:

const hasOwnProperty = Object.prototype.hasOwnProperty;const hasOwn = (val, key) => hasOwnProperty.call(val, key);

3.局部变量目标为3。JavaScript:

Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl

温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
未整理

雨婷《服装直播带货运营落地实操课》新号0粉快速带货日销10W+

2021-7-31 0:00:00

未整理

XnSay机器人授权系统源码

2021-8-2 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索