From 4d044952dc703d764485f791d65068bdb85c1b44 Mon Sep 17 00:00:00 2001 From: Ruan Yifeng Date: Wed, 14 Jan 2015 12:10:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9string/contains=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=94=B9=E4=B8=BAincludes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/string.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/string.md b/docs/string.md index 7c6b403..791bd34 100644 --- a/docs/string.md +++ b/docs/string.md @@ -265,11 +265,11 @@ normalize方法可以接受四个参数。 不过,normalize方法目前不能识别三个或三个以上字符的合成。这种情况下,还是只能使用正则表达式,通过Unicode编号区间判断。 -## contains(), startsWith(), endsWith() +## includes(), startsWith(), endsWith() 传统上,JavaScript只有indexOf方法,可以用来确定一个字符串是否包含在另一个字符串中。ES6又提供了三种新方法。 -- **contains()**:返回布尔值,表示是否找到了参数字符串。 +- **includes()**:返回布尔值,表示是否找到了参数字符串。 - **startsWith()**:返回布尔值,表示参数字符串是否在源字符串的头部。 - **endsWith()**:返回布尔值,表示参数字符串是否在源字符串的尾部。 @@ -279,7 +279,7 @@ var s = "Hello world!"; s.startsWith("Hello") // true s.endsWith("!") // true -s.contains("o") // true +s.includes("o") // true ``` @@ -291,7 +291,7 @@ var s = "Hello world!"; s.startsWith("o", 4) // true s.endsWith("o", 8) // true -s.contains("o", 8) // false +s.includes("o", 8) // false ```