Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 1-js/05-data-types/03-string/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ JavaScript 中有三种获取字符串的方法:`substring`、`substr` 和 `sl

```js run
let str = "stringify";
   alert( str.slice(0, 5) ); // 'strin', 从 0 到 5 的子字符串(不包括 5)
   alert( str.slice(0, 1) ); // 's', 从 0 到 1,但不包括 1,所以只有在 0 的字符
alert( str.slice(0, 5) ); // 'strin', 从 0 到 5 的子字符串(不包括 5)
alert( str.slice(0, 1) ); // 's', 从 0 到 1,但不包括 1,所以只有在 0 的字符
```

如果没有第二个参数,`slice` 运行到字符串末尾:
Expand Down Expand Up @@ -413,8 +413,8 @@ JavaScript 中有三种获取字符串的方法:`substring`、`substr` 和 `sl
alert( str.substring(2, 6) ); // "ring"
alert( str.substring(6, 2) ); // "ring"

   // ...但除了 slice:
   alert( str.slice(2, 6) ); // "ring" (the same)
// ...但除了 slice:
alert( str.slice(2, 6) ); // "ring" (the same)
alert( str.slice(6, 2) ); // "" (an empty string)

```
Expand Down