Repository navigation
Expand file tree
/
Copy pathlet.html
More file actions
145 lines (107 loc) · 2.53 KB
/
Copy pathlet.html
File metadata and controls
145 lines (107 loc) · 2.53 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
<script type="text/javascript">
// var a = []
// var defined i value is a gloabal, the i value wiil be pollution global variable
// for (let i = 0 ; i < 10 ; i++) {
// a[i] = () => {
// console.log(i)
// }
// a[i]()
// }
// bar = (y = x, y = 2) => {
// return [x, y];
// }
// function fe() { console.log('outside'); }
// (function () {
// if (false) {
// function fe() { console.log('inside'); }
// }
// fe();
// }());
// const a = []
// a.push('Hello')
// a.length = 0
// console.log(a)
// 解构赋值 模式匹配
var [a, b, c] = [1, 2, 3]
var node = {
loc: {
start: {
line: 1,
column: 5
}
}
}
var { loc: { start: { line, column } } } = node
console.log('line: ', line)
console.log('column: ', column)
let [head, ...footer] = [1, 2, 3, 4, 5]
var { x = 3 } = { x: null }
var { y = 4 } = { y: undefined }
// [[1, 2], [3, 4], [5, 6]].map(([a, b]) => a + b)
// function add(x = 3, y = 4) {
// return x + y
// }
// var u = 1
// var w = 2
// var [u , w] = [1, 2]
// [u, w] = [w, u];
let jsonData = {
id: 42,
status: 'OK',
data: [1, 2, 3, 4]
}
let { id, status, data } = jsonData
console.log(id, status, data)
// let str = 'Hello World'
let s = 'A'
console.log(s.padStart(6, 'Fan'))
console.log(s.padEnd(8, 'La'))
let num = 36.7
// 判断是否为整数
console.log('Number.isInteger 判断是否为整数', Number.isInteger(num))
// Number.isSafeInteger()
console.log(Math.trunc(13.37)) // 13
console.log(Math.floor(13.37)) // 13
// 判断是否为正数负数
console.log('-8', Math.sign(-8))
console.log('0', Math.sign(0))
console.log('8', Math.sign(8))
// 计算乘积 return a * b
console.log(Math.imul(5, 5))
// Array.from 也可以作用于深拷贝浅拷贝
let str = [2, 2, 8, 10]
let strs = Array.from(str) // 返回一个新的数组
strs.push(5)
// console.log(Array.from(strs, (x) => x + 1))
// 数组实例 copyWithin()
// find()
// 返回值
strs.find((value, index, arr) => { // 值,数组坐标位置,数组
return value > 3
})
// 返回下标
strs.findIndex((value, index, arr) => { // 值,数组坐标位置,数组
return value > 3
})
function Le(x, y = 'Fan') {
console.log(x, y)
}
function add (...values) {
let sum = 0;
for (var val of values) {
sum += val;
}
return sum;
}
</script>
</html>