Skip to content

Commit

Permalink
Docs: Update 'File Read and Write' and 'Class and Object' Sections fo…
Browse files Browse the repository at this point in the history
…r Clarity and Accuracy (#41)

* Docs: Update read-and-write-files.md

* Docs: Update class-and-instance.md
  • Loading branch information
baekilda authored Jan 2, 2024
1 parent 873e736 commit 2a375e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/class-and-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ console.log(circle.getArea()); // 78.53981633974483
console.log(circle.getCircumference()); // 31.41592653589793
```
:::tip
The `static` keyword in the class is not native to JavaScript, but a feature provided by TypeScript. In addition to `static`, TypeScript also provides access modifiers such as `public`, `private`, and `protected`.
The `static` keyword in classes is a feature provided by TypeScript, but starting from ES2022, it has been [natively supported](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static) in JavaScript. In addition, TypeScript also provides access modifiers such as `public`, `private`, and `protected`.
:::

#### Python implementation
Expand Down
9 changes: 4 additions & 5 deletions docs/read-and-write-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ const missingClassics = classics.filter(classic => !books.includes(classic));

if (missingClassics.length === 0) {
console.log('The file already contains the four great classical novels of China.');
return;
} else {
const missingClassicsText = missingClassics.join('\n');
fs.appendFileSync('books.txt', `\n${missingClassicsText}`, 'utf8');
console.log(`The missing novels have been added to the file: ${missingClassicsText}`);
}

const missingClassicsText = missingClassics.join('\n');
fs.appendFileSync('books.txt', `\n${missingClassicsText}`, 'utf8');
console.log(`The missing novels have been added to the file: ${missingClassicsText}`);
```

#### Python implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ console.log(circle.getArea()); // 78.53981633974483
console.log(circle.getCircumference()); // 31.41592653589793
```
:::tip
class 中的 `static` 关键字并非 JavaScript 原生支持的,而是由 TypeScript 提供的特性,除此之外还提供了 `public``private``protected` 访问修饰符。
class 中的 `static` 关键字原来是 TypeScript 提供的特性,但从 ES2022 起已经在JavaScript中[原生支持](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes/static)了。 除此之外,TypeScript 还提供了 `public``private``protected` 访问修饰符。
:::

#### Python 实现
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ const missingClassics = classics.filter(classic => !books.includes(classic));

if (missingClassics.length === 0) {
console.log('文件中已包含中国四大名著。');
return;
} else {
const missingClassicsText = missingClassics.join('\n');
fs.appendFileSync('books.txt', `\n${missingClassicsText}`, 'utf8');
console.log(`已补充缺失的名著到文件中: ${missingClassicsText}`);
}

const missingClassicsText = missingClassics.join('\n');
fs.appendFileSync('books.txt', `\n${missingClassicsText}`, 'utf8');
console.log(`已补充缺失的名著到文件中: ${missingClassicsText}`);
```

#### Python 实现
Expand Down

0 comments on commit 2a375e9

Please sign in to comment.