<!DOCTYPE html>
<html>
<head>
<title>jq中的isArray方法分析</title>
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
</head>
<body>
<div
class
=
"warp"
>
</div>
<script type=
"text/javascript"
>
var
class2type = {},core_toString = class2type.toString;
var
isArray = Array.isArray ||
function
( obj ) {
return
type(obj) ===
"array"
;
};
var
arr =
"Boolean Number String Function Array Date RegExp Object Error"
.split(
" "
);
for
(
var
i in arr){
class2type[
"[object "
+ arr[i] +
"]"
] = arr[i].toLowerCase();
};
var
type =
function
( obj ) {
if
( obj == null ) {
return
String( obj );
}
return
typeof obj ===
"object"
|| typeof obj ===
"function"
?
class2type[ core_toString.call(obj) ] ||
"object"
:
typeof obj;
};
</script>
</body>
</html>