From c40612041809fe289aba58aefa170bbe784aba1f Mon Sep 17 00:00:00 2001 From: t7yang Date: Mon, 10 Jan 2022 08:38:07 +0800 Subject: remove name attribute for zh-CN --- .../reference/global_objects/string/index.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/string/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/index.html index bcfc0bf5ec..6b8d96b0ac 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String

String 全局对象是一个用于字符串或一个字符序列的构造函数。

-

语法

+

语法

字符串字面量采取以下形式:

@@ -35,20 +35,20 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String
String(thing)
 new String(thing)
-

参数

+

参数

thing
任何可以被转换成字符串的值。
-

模板字面量

+

模板字面量

从 ECMAScript 2015 开始,字符串字面量也可以称为模板字面量

`hello world` `hello! world!` `hello ${who}` escape `<a>${who}</a>`
-

转义字符

+

转义字符

@@ -141,11 +141,11 @@ otherwise my code is unreadable.";
-

描述

+

描述

字符串对于保存可以以文本形式表示的数据非常有用。 一些常用的字符串操作有:查询字符串长度,使用 + 和 += 运算符来构建和连接字符串,使用 indexOf 方法检查某一子字符串在父字符串中的位置,又或是使用 substring 方法提取从父字符串中提取子字符串。

-

从字符串中获取单个字符

+

从字符串中获取单个字符

获取字符串的某个字符有两种方法。 第一种是使用 {{jsxref("String.charAt", "charAt")}} 方法:

@@ -159,7 +159,7 @@ otherwise my code is unreadable.";

使用括号访问字符串不可以对其进行删除或添加,因为字符串对应未知的属性并不是可读或配置的。 (更多的信息请参阅 {{jsxref("Object.defineProperty")}}。 )

-

字符串比较

+

字符串比较

熟练使用 C 语言的开发者经常使用 strcmp 函数来比较字符串,但在 JavaScript 中,你只需要使用比较操作符(>/</>=/<=)

@@ -212,7 +212,7 @@ console.log(eval(s2)); // returns the string "2 + 2"
可以为 String 对象增加新的属性。
-

方法

+

方法

{{jsxref("String.fromCharCode()")}}  
@@ -247,7 +247,7 @@ console.log(String.replace(num, /5/, '2'));

{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}} 在 Javascript 1.6 中同样支持{{jsxref("Global_Objects/Array", "Array")}}。

-

String 实例

+

String 实例

属性

-- cgit v1.2.3-54-g00ecf