其他分享
首页 > 其他分享> > js 判断数据类型

js 判断数据类型

作者:互联网

function getType(variable) 
return typeof variable === 'object' ? Object.prototype.toString.call(variable).replace('[object ', '').replace(']', '').toLowerCase() : typeof variable; }

 const numArr = [1,2,3];  getType(numArr); //array
 

 

标签:判断,getType,数据类型,object,js,typeof,numArr,variable,replace
来源: https://www.cnblogs.com/150536FBB/p/13345371.html