Skip to content

Commit f02ad73

Browse files
committed
Mention that new string methods throw an error when a regular expression s passed (fixes nzakas#47)
1 parent 74c8dbd commit f02ad73

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

manuscript/01-The-Basics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ These three methods make it much easier to identify substrings without needing t
224224

225225
I> All of these methods return a boolean value. If you need to find the position of a string within another, use `indexOf()` or `lastIndexOf()`.
226226

227+
W> The `startsWith()`, `endsWith()`, and `contains()` methods will throw an error if you pass a regular expression instead of a string. This stands in contrast to `indexOf()` and `lastIndexOf()`, which both convert a regular expression argument into a string and then search for that string.
228+
227229
### repeat()
228230

229231
ECMAScript 6 also adds a `repeat()` method to strings. This method accepts a single argument, which is the number of times to repeat the string, and returns a new string that has the original string repeated the specified number of times. For example:

0 commit comments

Comments
 (0)