fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@@ -0,0 +1,11 @@
---
title: Function Caller
localeTitle: 功能来电
---
## 功能来电
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-caller/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,11 @@
---
title: Function displayName
localeTitle: 功能displayName
---
## 功能displayName
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-displayname/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,39 @@
---
title: Function Length
localeTitle: 功能长度
---
## 功能长度
函数对象的`length`属性保存调用时函数所期望的参数数。
```javascript
function noArgs() { }
function oneArg(a) { }
console.log(noArgs.length); // 0
console.log(oneArg.length); // 1
```
### ES2015语法
ES2015或通常称为ES6引入了rest操作符和默认函数参数。这两个添加都改变了`length`属性的工作方式。
如果在函数声明中使用了rest运算符或默认参数`length`属性将仅包含rest运算符或默认参数之前的参数数。
```javascript
function withRest(...args) { }
function withArgsAndRest(a, b, ...args) { }
function withDefaults(a, b = 'I am the default') { }
console.log(withRest.length); // 0
console.log(withArgsAndRest.length); // 2
console.log(withDefaults.length); // 1
```
有关`Function.length`更多信息可以在[Mozilla的MDN Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length)上找到。

View File

@@ -0,0 +1,11 @@
---
title: Function Name
localeTitle: 功能名称
---
## 功能名称
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-name/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,11 @@
---
title: Function.prototype.apply
localeTitle: Function.prototype.apply的
---
## Function.prototype.apply的
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-prototype-apply/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,59 @@
---
title: Function.prototype.bind
localeTitle: Function.prototype.bind
---
## Function.prototype.bind
`bind`是JavaScript中所有函数原型的一种方法。 它允许您从现有函数创建新函数,更改新函数的`this`上下文,并提供您希望调用新函数的任何参数。 提供给`bind`的参数将在调用它之前传递给新函数的任何参数之前。
### 使用`bind`在函数中更改`this`
提供给`bind`的第一个参数是函数将`bind``this`上下文。 如果您不想`this`传递`null`的值更改为第一个参数。
您的任务是编写代码以更新与会者到达会议时的数量。 您创建一个简单的网页,其中包含一个按钮,单击该按钮`numOfAttendees` 关于confrence对象的属性。您使用jQuery向按钮添加单击处理程序但单击按钮后confrence对象未更改。您的代码可能看起来像这样。
```javascript
var nodevember = {
numOfAttendees: 0,
incrementNumOfAttendees: function() {
this.numOfAttendees++;
}
// other properties
};
$('.add-attendee-btn').on('click', nodevember.incrementNumOfAttendees);
```
使用jQuery和JavaScript时这是一个常见问题。当您单击按钮时传递给jQuery的`on`方法的方法中的`this`关键字引用按钮而不是会议对象。您可以绑定方法的`this`上下文来解决问题。
```javascript
var nodevember = {
numOfAttendees: 0,
incrementNumOfAttendees: function() {
this.numOfAttendees++;
}
// other properties
};
$('.add-attendee-btn').on('click', nodevember.incrementNumOfAttendees.bind(nodevember));
```
现在,当单击`this`按钮时, `nodevember`引用`nodevember`对象。
### 使用`bind`为函数提供参数
在第一个之后传递给`bind`每个参数都将在调用函数时传递的任何参数之前。 这允许您将参数预先应用于函数。在下面的示例中, `combineStrings`采用两个字符串并将它们连接在一起。然后使用`bind`创建一个始终提供“Cool”作为第一个字符串的函数。
```javascript
function combineStrings(str1, str2) {
return str1 + " " + str2
}
var makeCool = combineStrings.bind(null, "Cool");
makeCool("trick"); // "Cool trick"
```
[此参考](https://guide.freecodecamp.org/javascript/this-reference)的指南提供了有关`this`关键字引用的更改方式的更多信息。
关于`bind`方法的更多细节可以在Mozilla的[MDN文档中找到](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) 。

View File

@@ -0,0 +1,11 @@
---
title: Function.prototype.call
localeTitle: Function.prototype.call
---
## Function.prototype.call
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-prototype-call/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,11 @@
---
title: Function.prototype.isGenerator
localeTitle: Function.prototype.isGenerator
---
## Function.prototype.isGenerator
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-prototype-isgenerator/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,11 @@
---
title: Function.prototype.toSource
localeTitle: Function.prototype.toSource
---
## Function.prototype.toSource
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-prototype-tosource/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,11 @@
---
title: Function.prototype.toString
localeTitle: Function.prototype.toString
---
## Function.prototype.toString
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/function-prototype-tostring/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息:

View File

@@ -0,0 +1,11 @@
---
title: Function
localeTitle: 功能
---
## 功能
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/function/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
#### 更多信息: