isStrictArray

说明

判断是否严格的数组

源码

用法

isStrictArray.test.ts
1
import { isStrictArray } from "../../utility/array/isStrictArray";
2
3
describe('isStrictArray', () => {
4
test('isStrictArray should return `true` if received a strict array', () => {
5
const received = [
6
[],
7
[1, 2, 4],
8
[{}, {}],
9
];
10
11
for (const v of received) {
12
expect(isStrictArray(v)).toBeTruthy();
13
}
14
});
15
16
test('isStrictArray should return `false` if received a non array', () => {
17
document.body.innerHTML += `
18
<p></p>
19
<h3></h3>
20
<p></p>
21
`;
22
23
const received = [
24
{ a: 1, b: 2, length: 2 },
25
document.querySelectorAll('p'),
26
{ name: 'duan', age: 20 },
27
null,
28
undefined,
29
0,
30
'',
31
];
32
33
for (const v of received) {
34
expect(isStrictArray(v)).toBeFalsy();
35
}
36
});
37
});
Copied!
最近更新 1yr ago
复制链接