Skip to content

Commit 72426c5

Browse files
add instance _of
1 parent fdfda96 commit 72426c5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

instanceof.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// 模拟JS中的instance of,判断某个对象是否是另一个对象的实例。
2+
3+
function instance_of(V, F) {
4+
var O = F.prototype;
5+
V = V.__proto__;
6+
while (true) {
7+
if (V === null)
8+
return false;
9+
if (O === V)
10+
return true;
11+
V = V.__proto__;
12+
}
13+
}

0 commit comments

Comments
 (0)