freeCodeCamp/guide/chinese/javascript/standard-objects/string/string-fromcharcode/index.md

35 lines
868 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
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
```