GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — data-structure-and-algorithm-in-JavaScript/instanceOf.html at main · shaw-555/data-structure-and-algorithm-in-JavaScript

Expand file tree

/

instanceOf.html

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
53 lines (41 loc) · 1.33 KB
/

instanceOf.html

Copy path

File metadata and controls

53 lines (41 loc) · 1.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script>
function DNA(){
alert('I am shocked');
}
var a = new DNA();
function myInstanceOf(left,right){
if(typeof left !== 'object' || left === null) return false;
let proto = Object.getPrototypeOf(left);
while(true){
if(proto === null) return false;
if(proto === right.prototype) return true;
proto = Object.getPrototypeOf(proto);
}
}
// function myInstanceOf(left, right) {
// //基本数据类型直接返回false
// if(typeof left !== 'object' || left === null) return false;
// //getProtypeOf是Object对象自带的一个方法,能够拿到参数的原型对象
// let proto = Object.getPrototypeOf(left);
// while(true) {
// //查找到尽头,还没找到
// if(proto == null) return false;
// //找到相同的原型对象
// if(proto == right.prototype) return true;
// proto = Object.getPrototypeOf(proto);
// }
// }
var arr = 3;
var test = myInstanceOf(a,DNA);
console.log(test);
</script>
</html>
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.