菜单

贡献

相关源文件

本文档提供了为 JavaScript Questions 仓库做贡献的指南和说明。该仓库收集了带有多项选择题答案和详细解释的 JavaScript 面试题,并提供多种语言版本。本指南涵盖了如何提交新问题、改进现有问题、创建翻译以及参与维护这个宝贵的教育资源。

有关如何将本仓库用于学习目的的信息,请参阅 学习路径

来源: README.md6-12

贡献类型

The JavaScript Questions repository welcomes several types of contributions

  1. New Questions - Adding original JavaScript interview questions with multiple-choice answers and explanations
  2. Translations - Translating existing questions to languages not currently available
  3. Corrections - Fixing errors in code examples, explanations, or translations
  4. Improvements - Enhancing existing explanations or adding additional information

Sources: README.md12-19 README.md22-50

Question Format Guidelines

When contributing new questions or improving existing ones, follow the specific format used throughout the repository to maintain consistency.

Question Structure

Each question follows this structure

###### [question number]. [question title]

```javascript
[code example]
  • A: [option A]
  • B: [option B]
  • C: [option C]
  • D: [option D]
答案

Answer: [correct letter]

[detailed explanation of the answer]

```

This format includes

  1. A question number and title
  2. A JavaScript code snippet (when applicable)
  3. Multiple-choice options (typically 3-4 options)
  4. The correct answer hidden in a collapsible section
  5. A detailed explanation of why the answer is correct

Sources: README.md54-171

翻译指南

Translations are a crucial part of making the JavaScript questions accessible to a global audience. The repository already supports many languages, but new translations are always welcome.

Starting a New Translation

To start a new translation

  1. Create a new folder in the repository root with the appropriate language code (e.g., fr-FR for French)
  2. Copy the original English README.md file
  3. Translate the content while maintaining the structure and formatting
  4. Add your language to the list of available translations in the main README.md

Translation Folder Naming Convention

Use the ISO language code format for folder names

  • [language-code]-[COUNTRY-CODE] (e.g., es-ES for Spanish, zh-CN for Simplified Chinese)

Translation Contents

Ensure your translation includes

  1. The header section with repository title
  2. The introduction paragraph
  3. The collapsible translation list (update with your language)
  4. All questions and answers, maintaining the original numbering and structure

Sources: README.md22-50 nl-NL/README.md16-44 id-ID/README.md16-43

贡献流程

The following steps outline the process for contributing to the JavaScript Questions repository.

For New Questions

  1. Fork the Repository: Create your own fork of the repository
  2. Add Your Question: Follow the format guidelines to add a new question
  3. Place Correctly: Add your question to the end of the existing questions
  4. Test Your Code: Ensure any code examples work as expected
  5. Submit a Pull Request: Create a PR with a clear description of your contribution

For Translations

  1. Check if Translation Exists: Verify if your target language already exists
  2. Create Language Folder: If not, create a new folder with the appropriate language code
  3. Translate Content: Translate while maintaining the original format and structure
  4. Verify Formatting: Ensure all markdown and HTML formatting is preserved
  5. Submit a Pull Request: Create a PR with details about your translation

For Corrections and Improvements

  1. Identify the Issue: Find the specific problem in an existing question or translation
  2. Make Necessary Changes: Fix the issue while maintaining the overall structure
  3. Explain the Change: Provide clear reasoning for your correction
  4. Submit a Pull Request: Create a PR that clearly describes what you fixed and why

Sources: README.md16-18

拉取请求指南

When submitting a pull request, please follow these guidelines to ensure a smooth review process

  1. Clear Title: Use a descriptive title that indicates the type of contribution
  2. Detailed Description: Explain what your PR contains and why it's valuable
  3. Single Purpose: Each PR should address a single concern (new question, translation, etc.)
  4. Reference Issues: If your PR addresses an existing issue, reference it
  5. Follow Repository Style: Maintain the style and formatting of the existing content

JavaScript Concepts Coverage

When contributing new questions, consider focusing on these JavaScript concepts that the repository aims to cover comprehensively

类别主题
变量与作用域Hoisting, Temporal Dead Zone, Block vs. Global Scope, var vs. let vs. const
函数Arrow Functions, Regular Functions, this Context, Closures, IIFEs, Generators
对象与原型Object Creation, Prototype Chain, Constructor Functions, Classes, Property Access
Asynchronous JSEvent Loop, Promises, async/await, setTimeout/setInterval, Callbacks
Data Types & CoercionPrimitive Types, Reference Types, Type Conversion, Truthy & Falsy Values, Operators
ES6+ 特性Destructuring, Spread Operator, Rest Parameters, Template Literals, Modules
DOM 与事件Event Propagation, Event Bubbling, Event Delegation, DOM Manipulation

Sources: README.md63-147 README.md451-468

行为准则

When contributing to the JavaScript Questions repository, please adhere to these principles

  1. Be Respectful: Treat other contributors with respect and courtesy
  2. Stay Focused: Keep contributions relevant to the repository's purpose
  3. Quality First: Prioritize accuracy and educational value in your contributions
  4. Open to Feedback: Be receptive to feedback and willing to make adjustments
  5. Attribution: If your question is inspired by another source, provide proper attribution

识别

Contributors to the repository are valued members of the community. Your contributions help make JavaScript concepts more accessible to developers worldwide. The project author (Lydia Hallie) appreciates all contributors who help maintain and improve the repository.

Sources: README.md12-18

Question Example

Here's an example of how a question should be formatted

###### X. What's the output?

```javascript
function sayHi() {
  console.log(name);
  console.log(age);
  var name = 'Lydia';
  let age = 21;
}

sayHi();
  • A: Lydia and undefined
  • B: Lydia and ReferenceError
  • C: ReferenceError and 21
  • D: undefined and ReferenceError
答案

Answer: D

Within the function, we first declare the name variable with the var keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of undefined, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the name variable, so it still holds the value of undefined.

Variables with the let keyword (and const) are hoisted, but unlike var, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a ReferenceError.

```

Sources: README.md54-82

其他资源

To better understand JavaScript concepts and improve your contributions, consider these resources

  1. The JavaScript specification (ECMAScript)
  2. Mozilla Developer Network (MDN) JavaScript documentation
  3. Exploring existing questions in the repository to understand the style and depth expected

By following these guidelines, you'll help maintain the high quality of the JavaScript Questions repository and contribute to making JavaScript knowledge more accessible to developers around the world.