-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.html
98 lines (83 loc) · 2.73 KB
/
notes.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<title>notes</title>
<style>
.box {
width: 100%;
background: deepskyblue;
}
</style>
</head>
<body>
<div>
</div>
<div class="box"></div>
<script>
console.log(navigator)
// typeof 检测基本数据类型
console.log(typeof null) //object
console.log(typeof undefined) //undefined
console.log(typeof true) //boolean
console.log(typeof 5) //number
console.log(typeof "5") //string
console.log(typeof {}) //object
console.log(typeof function () { }) //function
console.log(typeof []) //object
// instanceof 检测引用数据类型
// console.log(null instanceof Null) //错误
// console.log(undefined instanceof Undefined) //错误
console.log({} instanceof Object)
console.log(function () { } instanceof Function)
console.log([] instanceof Array)
// constructor 构造函数指针
// console.log((null).constructor == Null) //错误
// console.log((undefined).constructor == Undefined) //错误
console.log((true).constructor == Boolean)
console.log((5).constructor == Number)
console.log(('5').constructor == String)
console.log({}.constructor == Object)
console.log((function () { }).constructor == Function)
console.log([].constructor == Array)
// jquery方法检测数据类型
var str = Object.prototype.toString;
var fn = function (v) {
var s = str.call(v);
var r = new RegExp("\\s(.*?)]");
var m = s.match(r) && s.match(r)[1];
return m
}
console.log(fn(null))
console.log(fn(undefined))
console.log(fn(true))
console.log(fn(5))
console.log(fn(""))
console.log(fn({}))
console.log(fn(function () { }))
console.log(fn([]))
</script>
<script>
// 正则获取url参数
var url = "https://www.zhihu.com/#/?name=张三&age=25&sex=男&id=";
function getUrlParams(name) {
var r = new RegExp("(^|\/?)" + name + "=([^|&]*)(&|$)");
var s = url.match(r);
return s ? s[2] : null;
}
console.log(getUrlParams("name"))
</script>
<script>
// vue实现原理
</script>
<script>
/* 前端面试 */
// 跨域解决方案
// 前端性能优化
// vue首屏加载优化
// 函数防抖与节流
// 前端加密
</script>
</body>
</html>