Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Aug 7, 2019
1 parent 86a2ee6 commit ab1d5c3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
19 changes: 19 additions & 0 deletions docs/interview/js.md
Expand Up @@ -356,6 +356,25 @@ console.log(sum(3)(4)(1)()) //8

`console.log(sum(3, 5)(4)(2, 1)(5)(3)()) //23`

```js
function add(arr) {
return arr.reduce((acc, cur) => {
acc = acc + cur
return acc
}, 0)
}

function sum(...args) {
return (...newArgs) => {
if (newArgs.length === 0) {
return add(args)
} else {
return sum(...args, ...newArgs)
}
}
}
```

### 13. 据下面的代码片段回答后面的问题

```js
Expand Down
9 changes: 9 additions & 0 deletions docs/interview/remember/code.md
Expand Up @@ -280,3 +280,12 @@ function foo() {
parseInt(0.0000008)
// parseInt(string, radix)是这样工作的:如果第一个参数不是string,则先使用toString()。 0.000008.toString()不会使用科学计数法,但0.0000008.toString()会变成科学计数法的"8e-7",所以parseInt(0.000008)就变成了parseInt("8e-7"),而这会被转成8
```

### 去首尾空格

```js
function trim(s) {
return s.replace(/^\s+/, '').replace(/\s+$/, '')
}
console.log(trim(' hellw wor ld '))
```
2 changes: 1 addition & 1 deletion docs/interview/remember/index.md
Expand Up @@ -472,4 +472,4 @@ docker 最大的好处的是快速回滚。
- [「中高级前端面试」JavaScript 手写代码无敌秘籍](https://juejin.im/post/5c9c3989e51d454e3a3902b6)
- [ECMAScript 6 简介](http://es6.ruanyifeng.com/#docs/intro) 学习 ES6 只推荐阮老师的教程
- [从浏览器多进程到 JS 单线程,JS 运行机制最全面的一次梳理](https://segmentfault.com/a/1190000012925872#articleHeader13)
- [](https://juejin.im/post/5d2ee123e51d4577614761f8)
- [20 道 JS 原理题助你面试一臂之力!](https://juejin.im/post/5d2ee123e51d4577614761f8)
7 changes: 7 additions & 0 deletions docs/interview/remember/js.md
Expand Up @@ -762,3 +762,10 @@ https://www.zhihu.com/question/24188524

https://github.com/piecioshka/test-freeze-vs-seal-vs-preventExtensions
https://stackoverflow.com/questions/21402108/difference-between-freeze-and-seal

### 内存泄漏

- 意外的全局变量
- 被遗忘的计时器或回调函数
- 闭包
- 脱离 DOM 的引用

0 comments on commit ab1d5c3

Please sign in to comment.