点击勘误issues (opens new window),哪吒感谢大家的阅读
# 反转链表
var reverseList = function(head) {
let prev = null;
let curr = head;
let next = null;
while (curr != null) {
next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}
return prev;
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# Set和Map
const numberSet = new Set();
numberSet.add(1);
console.log(numberSet);
// Set(1) {1}
// Set里面的值是不重复的
numberSet.has(1) // true
numberSet.size()
// forEach
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
const person = new Map()
person.set("name", "jeskson")
// for...of
1
2
3
2
3
# let和const
var 函数作用域, let const 块级作用域
← 链表