-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
getHookArgumentsLength.html
65 lines (60 loc) · 1.59 KB
/
getHookArgumentsLength.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
//判断数据 是否不等于 undefined或者null
function isDef(v) {
return v !== undefined && v !== null
}
//判断数据 是否是undefined或者null
function isUndef(v) {
return v === undefined || v === null
}
function getHookArgumentsLength(fn) {
if (isUndef(fn)) {
return false
}
console.log(fn)
var invokerFns = fn.fns;
if (isDef(invokerFns)) {
console.log(invokerFns)
// invoker
return getHookArgumentsLength(
Array.isArray(invokerFns) ?
invokerFns[0] :
invokerFns
)
} else {
console.log(fn.length)
debugger
return (fn._length || fn.length) > 1
}
}
/*
数据必须是这样才返回真,也可以是n层fns只要规律是一样嵌套下去就行
var fn1=[1,2,3,4];
var fn={
fns:[
[1,2,3,45,34]
]
}
var fn2={
fns:[
{
fns:[
{
fns:[[1,2,3,45,9]]
}
]
}
]
}
*/
console.log(getHookArgumentsLength(fn))
</script>
</body>
</html>