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,13 @@
---
title: String
localeTitle: 串
---
## 串
在JavaScript中 `String`全局对象是字符串的构造函数,用于存储一系列字符。字符串可以以文字的形式创建,例如`var greeting = "Hi, campers!";`或使用`String`构造函数: `var greeting = new String("Hi, campers!");`
不像一些其他语言如果你使用一个JavaScript不关心`' '`或双`" "`引号的字符串。你甚至可以_在_字符串中使用它们它们只需要与包含字符串的引号不同`"Isn't that awesome?"`
#### 更多信息:
[MDN网络文档](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) [w3schools.com](https://www.w3schools.com/jsref/jsref_obj_string.asp)

View File

@@ -0,0 +1,35 @@
---
title: String fromCharCode
localeTitle: 字符串fromCharCode
---
静态`String.fromCharCode()`方法返回使用指定的Unicode值序列创建的字符串。
## 句法
```
String.fromCharCode(num1[, ...[, numN]])
```
### 参数
**num1...numN**
一系列Unicode值的数字。
[MDN链接](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) | [MSDN链接](https://msdn.microsoft.com/en-us/LIBRary/wb4w0k66%28v=vs.94%29.aspx)
## 描述
此方法返回字符串而不是String对象。
因为`fromCharCode()`是String的静态方法所以始终将其用作`String.fromCharCode()` 而不是您创建的String对象的方法。
## 例子
```
String.fromCharCode(65, 66, 67); // "ABC"
var test = String.fromCharCode(112, 108, 97, 105, 110);
document.write(test);
// Output: plain
```

View File

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

View File

@@ -0,0 +1,49 @@
---
title: String Length
localeTitle: 字符串长度
---
`length`属性表示字符串的长度。
## 句法
```
str.length
```
[MDN链接](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) | [MSDN链接](https://msdn.microsoft.com/en-us/LIBRary/3d616214%28v=vs.94%29.aspx)
## 描述
此属性返回字符串中的代码单元数。 UTF-16是JavaScript使用的字符串格式使用单个16位代码单元来表示最常见的字符但需要使用两个代码单元来表示不常用的字符因此有可能将长度返回的值返回到不匹配字符串中的实际字符数。
对于空字符串长度为0。
静态属性`String.length`返回值1。
## 例子
```
var x = 'Mozilla';
var empty = '';
console.log('Mozilla is ' + x.length + ' code units long');
/* "Mozilla is 7 code units long" */
console.log('The empty string has a length of ' + empty.length);
/* "The empty string has a length of 0" */
var str = "every good boy does fine";
var start = 0;
var end = str.length - 1;
var tmp = "";
var arr = new Array(end);
while (end >= 0) {
arr[start++] = str.charAt(end--);
}
// Join the elements of the array with a
var str2 = arr.join('');
document.write(str2);
// Output: enif seod yob doog yreve
```

View File

@@ -0,0 +1,40 @@
---
title: String.prototype.charAt
localeTitle: String.prototype.charAt
---
`charAt()`方法从字符串返回指定的字符。
## 句法
```
str.charAt(index)
```
## 参数
**指数**
一个介于0和1之间的整数小于字符串的长度。
[MDN链接](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt) | [MSDN链接](https://msdn.microsoft.com/en-us/LIBRary/65zt5h10%28v=vs.94%29.aspx)
## 描述
字符串中的字符从左到右编制索引。第一个字符的索引是0字符串中名为`stringName`的最后一个字符的索引是`stringName.length - 1` 。如果您提供的索引超出范围JavaScript将返回一个空字符串。
## 例子
```
var anyString = 'Brave new world';
console.log("The character at index 0 is '" + anyString.charAt(0) + "'"); // 'B'
console.log("The character at index 1 is '" + anyString.charAt(1) + "'"); // 'r'
console.log("The character at index 2 is '" + anyString.charAt(2) + "'"); // 'a'
console.log("The character at index 3 is '" + anyString.charAt(3) + "'"); // 'v'
console.log("The character at index 4 is '" + anyString.charAt(4) + "'"); // 'e'
console.log("The character at index 999 is '" + anyString.charAt(999) + "'"); // ''
var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.write(str.charAt(str.length - 1));
// Output: Z
```

View File

@@ -0,0 +1,35 @@
---
title: String.prototype.charCodeAt
localeTitle: String.prototype.charCodeAt
---
`charCodeAt()`方法返回给定索引处字符的数字Unicode值unicode代码点> 0x10000除外
## 句法
```
str.charCodeAt(index)
```
### 参数
**指数**
大于或等于0且小于字符串长度的整数;如果它不是数字则默认为0。
[MDN链接](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) | [MSDN链接](https://msdn.microsoft.com/en-us/LIBRary/hza4d04f%28v=vs.94%29.aspx)
## 描述
请注意, `charCodeAt()`将始终返回小于65536的值。这是因为较高的代码点由一对较低值“代理”伪字符表示这些伪字符用于构成真实字符。因此为了检查或重现值为65536及以上的单个字符的完整字符对于这些字符不仅需要检索`charCodeAt(i)` ,还需要检索`charCodeAt(i+1)` (就像检查一样) /再现两个字母的字符串。见下面的例2和3。
如果给定`index`小于0或等于或大于字符串的长度`charCodeAt()`返回`NaN`
## 例子
```
'ABC'.charCodeAt(0); // returns 65
var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.write(str.charCodeAt(str.length - 1));
// Output: 90
```

View File

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

View File

@@ -0,0 +1,37 @@
---
title: String.prototype.concat
localeTitle: String.prototype.concat
---
concat方法组合了两个或多个字符串的文本并返回一个新字符串。
**句法**
```
str.concat(string2[,..., stringN]);
```
## 参数
**string2 ... string _N_**要连接到此String的字符串。
[MDN链接](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat)
## 描述
concat方法组合了两个或多个字符串的文本并返回连接的字符串。它不会修改原始字符串。
## 例子
**连接字符串**
```JavaScript
var str1 = "Hello";
var str2 = "World";
console.log(str1.concat(str2));
// Console will output: HelloWorld
var str2 = "Hello, ";
console.log(str2.concat(" Welcome ", "to FCC."));
// Console will output: Hello, Welcome to FCC.
```
来源\[MDN\]

View File

@@ -0,0 +1,24 @@
---
title: String.prototype.endsWith
localeTitle: String.prototype.endsWith
---
## String.prototype.endsWith
`endsWith()`方法检查字符串是否以字符串输入结束并返回布尔值。
### 例如
```js
let str = "Hello world";
let bool = str.endsWith("ld") // true
bool = str.endsWith("llo") // false
```
此方法还可以接受另一个参数,即在搜索字符串的字符之前确定的`length`
```js
let str = "Hello world";
let bool = str.endsWith("ld", 5) // false, it's the same as "Hello".endsWith("ld")
bool = str.endsWith("llo", 5) // true, it's the same as "Hello".endsWith("llo")
```

View File

@@ -0,0 +1,59 @@
---
title: String.prototype.includes
localeTitle: String.prototype.includes
---
## String.prototype.includes
这是一个存根。 [帮助我们的社区扩展它](https://github.com/freecodecamp/guides/tree/master/src/pages/javascript/standard-objects/string/string-prototype-includes/index.md) 。
[这种快速风格指南有助于确保您的拉取请求被接受](https://github.com/freecodecamp/guides/blob/master/README.md) 。
`includes()`方法用于确定是否可以在另一个字符串中找到一个字符串。此方法返回布尔值( `true``false` )。
需要注意的是,此方法区分大小写。
**句法**
```js
string.includes(searchString[, position])
```
**参数**
此方法只需要一个参数searchString。但是通过包含第二个参数位置您可以从searchString中的特定位置或索引开始搜索字符串中的字符串。
**例子**
```js
let string = "Roses are red, violets are blue.";
string.includes('red'); // returns true
```
```javascript
let string = "Roses are red, violets are blue.";
string.includes('Red'); // returns false
```
```javascript
let string = "Roses are red, violets are blue.";
string.includes('red',12); // returns false because 'red' starts at position 9, and our search begins at position 12.
```
```javascript
let string = "Roses are red, violets are blue.";
string.includes('blue',12); // returns true because 'blue' starts after our search begins at position 12.
```
```javascript
let string = "Roses are red, violets are blue.";
string.includes('violets are blue'); // returns true
```
#### 更多信息:
[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)

View File

@@ -0,0 +1,44 @@
---
title: String.prototype.indexOf
localeTitle: String.prototype.indexOf
---
## String.prototype.indexOf
`indexOf()`方法返回可在数组中找到给定元素的第一个索引。如果该元素不存在,则返回-1。
**句法**
```javascript
str.indexOf(searchValue[, fromIndex])
```
### 参数
* 您正在查找的**searchValue**子字符串。如果这是空的( `''` )并且没有`fromIndex`参数则返回0。
* **fromIndex**可选。要开始搜索的索引。如果`fromIndex`值大于或等于字符串的长度,则不搜索该字符串,并且该方法返回-1。如果`searchValue`是一个空字符串( `''` )并且`fromIndex`小于字符串的长度,它将返回`fromIndex` ;否则,它将返回字符串的长度。 (负数将被视为没有参数。)
### 描述
`indexOf()`方法从左到右检查字符串。第一个字符的索引是0;最后一个字符的索引是`string.length - 1` 。该方法使用严格相等( `===` )针对`searchValue`检查每个子字符串,这意味着此方法区分大小写。一旦找到返回`true`的子字符串,它就会返回其第一个字符的索引。
### 例子
```javascript
'Blue Whale'.indexOf('Blue'); // returns 0
'Blue Whale'.indexOf('Blute'); // returns -1
'Blue Whale'.indexOf('Whale', 0); // returns 5
'Blue Whale'.indexOf('Whale', 5); // returns 5
'Blue Whale'.indexOf('Whale', 7); // returns -1
'Blue Whale'.indexOf(''); // returns 0
'Blue Whale'.indexOf('', 9); // returns 9
'Blue Whale'.indexOf('', 10); // returns 10
'Blue Whale'.indexOf('', 11); // returns 10
'Blue Whale'.indexOf('blue'); // returns -1
```
### 更多信息:
* MDN文档 [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf)
* MSDN文档 [MSDN](https://docs.microsoft.com/en-us/scripting/javascript/reference/indexof-method-string-javascript)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,21 @@
---
title: String.prototype.repeat
localeTitle: String.prototype.repeat
---
## String.prototype.repeat
`.repeat(n)`方法获取整数参数,并返回重复`n`次的字符串。
### 例如
```js
let str = "test";
console.log(str.repeat(3)); // "testtesttest", test is repeated 3 times
// NB
console.log(str.repeat(2.5)); // "testtest", 2.5 is converted to an integer and test is repeated 2 times
```
#### 更多信息
[MDN - String.prototype.repeat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)

View File

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

View File

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

View File

@@ -0,0 +1,47 @@
---
title: String.prototype.slice
localeTitle: String.prototype.slice
---
JavaScript字符串方法`.slice()`提取字符串的一部分并返回一个新字符串。
## 句法
```
str.slice(beginSliceIndex [, endSliceIndex]);
```
## 参数
**beginSliceIndex**
切片应该从零开始的索引。如果beginSliceIndex是负数`.slice()`从字符串的末尾开始向后计数,以确定从哪里开始切片。
**endSliceIndex**
可选的。切片应该结束的从零开始的索引。如果省略, `.slice()`提取到字符串的末尾。
[MDN链接](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)
## 描述
`.slice()`将文本切成一个字符串并返回一个新字符串。
## 例子
**使用`.slice()`创建一个新字符串**
```
var string1 = "Hello World!";
var string2 = string1.slice(3);
console.log(string2); // Will log "lo World!"
var string3 = string1.slice(3, 7);
console.log(string3); // Will log "lo W"
```
**使用带有负索引的`.slice()`**
```
var string = "Hello World!"
str.slice(-3); // Returns "ld!"
str.slice(-3, -1); // Returns "ld"
str.slice(0, -1); // Returns "Hello World"
```

View File

@@ -0,0 +1,40 @@
---
title: String.prototype.split
localeTitle: String.prototype.split
---
## String.prototype.split
`split()`函数根据您作为输入传递的_分隔符字符串_将原始字符串分隔为子_字符串_ 。
`split()`函数的输出是一个字符串`Array` ,表示原始字符串中的分隔子字符串。
`split()`函数不会更改原始字符串。
例子:
```js
// We have a regular string
"Hello. I am a string. You can separate me."
// Let's use the split function to separate the string by the period character:
"Hello. I am a string. You can separate me.".split(".");
// output is [ "Hello", " I am a string", " You can separate me", "" ]
```
由于我们使用句点( `.` 作为_分隔符字符串_ ,因此输出数组中的字符串不包含句点;输出分隔的字符串_不包括输入分隔符字符串本身_ 。
_字符串分隔符_不必是单个字符它可以是任何其他字符串
```js
"Hello... I am another string... keep on learning!".split("...");
// output is [ "Hello", " I am another string", " keep on learning!" ]
const names = "Kratos- Atreus- Freya- Hela- Thor- Odin";
// notice separator is a dash and a space
names.split("- ");
// output is [ "Kratos", "Atreus", "Freya", "Hela", "Thor", "Odin" ]
```
#### 更多信息:
* [MDN上的String.prototype.split](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)

View File

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

View File

@@ -0,0 +1,33 @@
---
title: String.prototype.substr
localeTitle: String.prototype.substr
---
## String.prototype.substr
substr方法从指定位置的字符开始提取字符串的一部分并返回指定数量的字符。
#### 句法
```JavaScript
string.substr(start, length);
```
#### 参数值
|参数|说明| | ------------- | ------------- | |开始| **需要。**开始提取的位置。第一个字符位于索引0处。 如果_start_为正且大于或等于字符串的长度则substr返回一个空字符串。 如果_start_为负数则substr将其用作字符串末尾的字符索引。 如果_start_为负或大于字符串的长度则start设置为0 | |长度| **可选** 。要提取的字符数。如果省略,则提取字符串的其余部分
#### 例子:
```JavaScript
let str = "Hello world!";
let res = str.substr(1, 4);
```
res的结果将是
```
ello
```
#### 更多信息:
[JavaScript String substr方法](https://www.w3schools.com/jsref/jsref_substr.asp) 。

View File

@@ -0,0 +1,30 @@
---
title: String.prototype.substring
localeTitle: String.prototype.substring
---
## String.prototype.substring
`substring()`函数从另一个给定的字符串中_提取_一系列字符。它不会改变原始字符串。
您可以使用_开始和结束字符索引_定义要提取的序列。这些索引作为参数传递给`substring()`函数。子字符串由起始索引的字符一直到结束索引的字符形成。两个索引都从字符串的开头开始计算,从`0`开始计算。
例子:
```js
"Hello, campers".substring(7, 14);
// output is "campers"
"Hello, world".substring(0, 5);
// output is "Hello"
```
您还可以省略最后一个字符索引参数,子字符串序列将从开始索引中提取,直到字符串结束。例:
```js
"Hello, campers!".substring(7);
// output is "campers!"
```
#### 更多信息:
* [MDN上的String.prototype.substring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring)

View File

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

View File

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

View File

@@ -0,0 +1,25 @@
---
title: String.prototype.toLowerCase
localeTitle: String.prototype.toLowerCase
---
JavaScript数组方法`.toLowerCase()`将返回转换为小写的字符串的值。原始字符串不会更改。
**句法**
```javascript
string.toLowerCase()
```
## 例子
```javascript
var shout = "I AM SHOUTING VERY LOUDLY"
var whisper = shout.toLowerCase()
console.log(shout) // will return "I AM SHOUTING VERY LOUDLY"
console.log(whisper) // will return "i am shouting very loudly"
```
#### 更多信息:
资料来源: [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)

View File

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

View File

@@ -0,0 +1,17 @@
---
title: String.prototype.toUpperCase
localeTitle: String.prototype.toUpperCase
---
JavaScript方法`.toUpperCase()`返回调用它的相同字符串,但全部大写。
**句法**
```
str.toUpperCase()
```
## 例子
```
console.log("hello world".toUpperCase()); // Console will output "HELLO WORLD"
```
来源[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)

View File

@@ -0,0 +1,22 @@
---
title: String.prototype.trim
localeTitle: String.prototype.trim
---
## String.prototype.trim
`trim()`函数从给定字符串的开头和结尾删除任何空格字符。它不会修改原始字符串;它输出一个新的。
例子:
```js
" Hello, campers. I have spaces on both ends! ".trim();
// output is "Hello, campers. I have spaces on both ends!"
```
`trim()`不仅删除空格字符;它会删除任何空白字符,例如制表符,换行符,不间断空格等。
这很有用,例如,当您想要处理来自用户的文本输入时,他们可能已经提交了一个字符串,其中包含您可能不想要的末尾空格。
#### 更多信息:
* [MDN上的String.prototype.trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)

View File

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

View File

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

View File

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

View File

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