-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yangjin
committed
Sep 25, 2019
1 parent
cfc6196
commit 4a7049b
Showing
47 changed files
with
151 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,103 @@ | ||
module.exports = { | ||
title: 'Hello VuePress', | ||
description: 'Just playing around', | ||
|
||
// webpack alias | ||
title: 'fe-tutorial', | ||
description: '前端学习笔记', | ||
head: [ | ||
['link', {rel: 'icon', href: '/favicon.ico'}] | ||
], | ||
configureWebpack: { | ||
resolve: { | ||
alias: { | ||
'@alias': 'path/to/some/dir' | ||
} | ||
} | ||
}, | ||
|
||
// base path | ||
base: '/docs/' | ||
base: '/fe-tutorial/', | ||
themeConfig: { | ||
editLinkText: '在 GitHub 上编辑此页', | ||
lastUpdated: '上次更新', | ||
nav: [ | ||
{ text: '数据结构和算法', link: '/algorithm/' }, | ||
{ text: 'JavaScript', link: '/javaScript/' }, | ||
{ text: 'Webpack', link: '/webpack/' }, | ||
{ text: '个人博客', link: 'https://yangseas.github.io/' }, | ||
{ text: 'github', link: 'https://github.com/yangseas' }, | ||
], | ||
sidebarDepth: 2, | ||
sidebar: { | ||
'/algorithm/': [ | ||
{ | ||
title: '数据结构', | ||
collapsable: false, | ||
sidebarDepth: 2, | ||
children: [] | ||
}, | ||
{ | ||
title: '算法', | ||
collapsable: false, | ||
sidebarDepth: 2, | ||
children: [] | ||
} | ||
], | ||
'/javaScript/': [ | ||
{ | ||
title: 'JavaScript', | ||
collapsable: false, | ||
sidebarDepth: 2, | ||
children: [ | ||
['', '介绍'], | ||
'执行上下文和执行栈', | ||
'作用域和闭包', | ||
'this', | ||
'原型链', | ||
'深拷贝和浅拷贝', | ||
'节流函数和防抖函数', | ||
'函数柯里化', | ||
'高阶函数', | ||
'EventEmitter', | ||
'实现ES5继承', | ||
'实现call,apply和bind', | ||
'实现Promise', | ||
'实现instanceof', | ||
'实现异步打印', | ||
'数组去重,扁平化和最值', | ||
'数组乱序', | ||
'懒加载', | ||
'滚动加载', | ||
'虚拟滚动' | ||
] | ||
}, | ||
{ | ||
title: 'RegExp', | ||
collapsable: false, | ||
sidebarDepth: 2, | ||
children: [ | ||
'RegExp', | ||
] | ||
} | ||
], | ||
'/webpack/': [ | ||
{ | ||
title: 'Webpack', | ||
collapsable: false, | ||
sidebarDepth: 2, | ||
children: [ | ||
['', '介绍'], | ||
'webpack打包过程', | ||
] | ||
}, | ||
{ | ||
title: 'vue-cli2模板解析', | ||
collapsable: false, | ||
sidebarDepth: 2, | ||
children: [ | ||
['vue-cli2介绍', '介绍'], | ||
'vue-cli2模板解析', | ||
] | ||
} | ||
], | ||
} | ||
}, | ||
plugins: [ | ||
['@vuepress/back-to-top', true] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// 添加额外样式 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// 对默认预设的样式应用简单的颜色替换,或者定义一些颜色变量供以后使用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: 函数柯里化 | ||
--- | ||
|
||
## 定义 | ||
|
||
在数学和计算机科学中,柯里化是一种将使用多个参数的一个函数转换成一系列使用一个参数的函数的技术。 | ||
|
||
> 通俗易懂的解释:用闭包把参数保存起来,当参数的数量足够执行函数了,就开始执行函数。 | ||
|
||
## 实现 | ||
|
||
- 判断当前函数传入的参数是否大于或等于`fn`需要参数的数量,如果是,直接执行`fn` | ||
- 如果传入参数数量不够,返回一个闭包,暂存传入的参数,并重新返回`currying`函数 | ||
|
||
```js | ||
function currying(fn, ...args) { | ||
if (args.length >= fn.length) { | ||
return fn(...args); | ||
} else { | ||
return (...args2) => currying(fn, ...args, ...args2); | ||
} | ||
} | ||
``` | ||
|
||
我们来一个简单的实例验证一下: | ||
|
||
```js | ||
const curryingFun = currying(fun) | ||
curryingFun(1)(2)(3); // 1 2 3 | ||
curryingFun(1, 2)(3); // 1 2 3 | ||
curryingFun(1, 2, 3); // 1 2 3 | ||
``` | ||
|
||
## 应用场景 | ||
|
||
### 参数复用 | ||
|
||
```js | ||
function getUrl(protocol, domain, path) { | ||
return protocol + "://" + domain + "/" + path; | ||
} | ||
|
||
var page1 = getUrl('http', 'www.conardli.top', 'page1.html'); | ||
var page2 = getUrl('http', 'www.conardli.top', 'page2.html'); | ||
``` | ||
|
||
我们使用`currying`来简化它: | ||
|
||
```js | ||
let conardliSite = currying(simpleURL)('http', 'www.conardli.top'); | ||
let page1 = conardliSite('page1.html'); | ||
``` |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.