From 2a375e93b6a1167c294ca90eb57bb8e2af48b845 Mon Sep 17 00:00:00 2001 From: Baekilda Date: Tue, 2 Jan 2024 15:25:14 +0900 Subject: [PATCH] Docs: Update 'File Read and Write' and 'Class and Object' Sections for Clarity and Accuracy (#41) * Docs: Update read-and-write-files.md * Docs: Update class-and-instance.md --- docs/class-and-instance.md | 2 +- docs/read-and-write-files.md | 9 ++++----- .../current/class-and-instance.md | 2 +- .../current/read-and-write-files.md | 9 ++++----- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/class-and-instance.md b/docs/class-and-instance.md index 203e61a..c410fff 100644 --- a/docs/class-and-instance.md +++ b/docs/class-and-instance.md @@ -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 diff --git a/docs/read-and-write-files.md b/docs/read-and-write-files.md index d908048..1dffa0a 100644 --- a/docs/read-and-write-files.md +++ b/docs/read-and-write-files.md @@ -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 diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/class-and-instance.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/class-and-instance.md index 7026709..66bdacb 100755 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/class-and-instance.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/class-and-instance.md @@ -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 实现 diff --git a/i18n/zh-cn/docusaurus-plugin-content-docs/current/read-and-write-files.md b/i18n/zh-cn/docusaurus-plugin-content-docs/current/read-and-write-files.md index a431e6f..ecb98dd 100755 --- a/i18n/zh-cn/docusaurus-plugin-content-docs/current/read-and-write-files.md +++ b/i18n/zh-cn/docusaurus-plugin-content-docs/current/read-and-write-files.md @@ -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 实现