home
Backend
Programming Language
Database
Message Queue
Microservice
Security
Operating System
Frontend
JavaScript
TypeScript
Vue
React
Design
Hobby
Metaphysics
Music
一切福田,不離方寸,從心而覓,感無不通。
判断一个js对象是不是数组
function isArray(o) {
return
Object.prototype.toString.call(o) ===
'[object Array]'
;
}
判断更多特殊类型:
var is = {
types : [
"Array"
,
"RegExp"
,
"Date"
,
"Number"
,
"String"
,
"Object"
,
"HTMLDocument"
]
};
for
(var i=
0
,c;c=is.types[i++];){
is[c] = (function(type){
return
function(obj){
return
Object.prototype.toString.call(obj) == “[object
"+type+"
]“;
}
})(c);
}
Post navigation
◀ 关于session超时问题
分享10个便利的HTML5/CSS3框架 ▶
Copyright © 2024
Longsheng
All rights reserved