From e6fdfceb2ad9093fdc2b5b58a0f18cd336218f7e Mon Sep 17 00:00:00 2001 From: Lellansin Date: Mon, 4 Dec 2017 12:36:34 +0800 Subject: [PATCH 01/18] Network: fix cors detail --- sections/zh-cn/network.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/network.md b/sections/zh-cn/network.md index 8062d80..6c183bd 100644 --- a/sections/zh-cn/network.md +++ b/sections/zh-cn/network.md @@ -182,7 +182,7 @@ HTTP headers 是在进行 HTTP 请求的交互过程中互相支会对方一些 > 什么是跨域请求? 如何允许跨域? -出于安全考虑, 默认情况下使用 XMLHttpRequest 和 Fetch 发起 HTTP 请求必须遵守同源策略, 即只能向相同域名请求. 向不同域名的请求被称作跨域请求 (cross-origin HTTP request). 可以通过设置 [CORS headers](https://developer.mozilla.org/en-US/docs/Glossary/CORS) 即 `Access-Control-Allow-` 系列来允许跨域. 例如: +出于安全考虑, 默认情况下使用 XMLHttpRequest 和 Fetch 发起 HTTP 请求必须遵守同源策略, 即只能向相同 host 请求 (host = hostname : port). 向不同 host 的请求被称作跨域请求 (cross-origin HTTP request). 可以通过设置 [CORS headers](https://developer.mozilla.org/en-US/docs/Glossary/CORS) 即 `Access-Control-Allow-` 系列来允许跨域. 例如: ``` location ~* ^/(?:v1|_) { From 67e5b990e422c3620d0ecfd34314584c1fefd81e Mon Sep 17 00:00:00 2001 From: Lellansin Date: Mon, 4 Dec 2017 15:26:09 +0800 Subject: [PATCH 02/18] Network: add https tip for http cors --- sections/zh-cn/network.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sections/zh-cn/network.md b/sections/zh-cn/network.md index 6c183bd..17d6ff8 100644 --- a/sections/zh-cn/network.md +++ b/sections/zh-cn/network.md @@ -182,7 +182,7 @@ HTTP headers 是在进行 HTTP 请求的交互过程中互相支会对方一些 > 什么是跨域请求? 如何允许跨域? -出于安全考虑, 默认情况下使用 XMLHttpRequest 和 Fetch 发起 HTTP 请求必须遵守同源策略, 即只能向相同 host 请求 (host = hostname : port). 向不同 host 的请求被称作跨域请求 (cross-origin HTTP request). 可以通过设置 [CORS headers](https://developer.mozilla.org/en-US/docs/Glossary/CORS) 即 `Access-Control-Allow-` 系列来允许跨域. 例如: +出于安全考虑, 默认情况下使用 XMLHttpRequest 和 Fetch 发起 HTTP 请求必须遵守同源策略, 即只能向相同 host 请求 (host = hostname : port) 注[1]. 向不同 host 的请求被称作跨域请求 (cross-origin HTTP request). 可以通过设置 [CORS headers](https://developer.mozilla.org/en-US/docs/Glossary/CORS) 即 `Access-Control-Allow-` 系列来允许跨域. 例如: ``` location ~* ^/(?:v1|_) { @@ -197,6 +197,8 @@ location ~* ^/(?:v1|_) { } ``` +注[1]:同源除了相同 host 也包括相同协议. 所以即使 host 相同, 从 HTTP 到 HTTPS 也属于跨域, 见[讨论](https://github.com/ElemeFE/node-interview/issues/55). + > `Script error.` 是什么错误? 如何拿到更详细的信息? 接上题, 由于同源性策略 (CORS), 如果你引用的 js 脚本所在的域与当前域不同, 那么浏览器会把 onError 中的 msg 替换为 `Script error.` 要拿到详细错误的方法, 处理配好 `Access-Control-Allow-Origin` 还有在引用脚本的时候指定 `crossorigin` 例如: From c8c9f6e2236db8592a9c66ab2bb2ec45af9dc298 Mon Sep 17 00:00:00 2001 From: Chuck Date: Tue, 5 Dec 2017 21:51:41 +0800 Subject: [PATCH 03/18] Section Util: update glob example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 最后一个小例子好像有点问题 --- sections/zh-cn/util.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sections/zh-cn/util.md b/sections/zh-cn/util.md index c49f404..70ef812 100644 --- a/sections/zh-cn/util.md +++ b/sections/zh-cn/util.md @@ -221,10 +221,12 @@ console.log(traversal('.')); ```javascript const glob = require("glob"); -glob("**/*.js", (err, files) { +glob("**/*.js", (err, files) => { if (err) { throw new Error(err); } - console.log('Here you are:', files.map(path.basename)); + files.map((filename) => { + console.log('Here you are:', filename); + }); }); ``` From abffdbc98c2633586c10687742442be619860aea Mon Sep 17 00:00:00 2001 From: David Zhang Date: Sun, 17 Dec 2017 16:25:47 +0800 Subject: [PATCH 04/18] section: common, translate the basis (#57) * Translate [common] type judgement * Add scope and reference --- sections/en-us/common.md | 43 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/sections/en-us/common.md b/sections/en-us/common.md index bf57d96..08c5269 100644 --- a/sections/en-us/common.md +++ b/sections/en-us/common.md @@ -1,13 +1,48 @@ # Basic -* `[Common]` Type judgment -* `[Common]` Scope -* `[Common]` Reference +* [`[Common]` Type judgment](/sections/en-us/common.md#Type-judgement) +* [`[Common]` Scope](/sections/en-us/common.md#Scope) +* [`[Common]` Reference](/sections/en-us/common.md#Reference) * `[Common]` Memory release * `[Common]` ES6+ features ## Summary -With diffrence between frontend, there are few chance to work with DOM in backend. So we won't discuss about it. Unlike browser side, backend is directly facing memory, while the work duration is calculated by year, we do more concern about the machine side. +In contrast to frontend, there are few chances to work with DOM in backend, unless we deal with SSR or web crawlers. So we won't discuss about it. Unlike browser side, backend faces memory directly, we concern more about the fundamental knowledge. +## Type judgement +We suffer tortuously from type judgement in JavaScript. Otherwise, TypeScript may not be created. Basically, we recommend to read the source code of [lodash](https://github.com/lodash/lodash). + +Generally, this is a simple opening of an interview. We won't deny a candidate only because of not knowing the value of `undefined == null` is `true`. According to our personal experiences, candidate who cannot answer this question is probably to have a poor foundation. If you have no concept of such kind of question, you may reflect on whether to find a JavaScript book to review for basis. + +Additionally, it is a bonus point if candidate understands TypeScript or flow. + +## Scope + +In an interview, scope is not an easy-to-ask knowledge point but critical in JavaScript. Eleme typically asks questions like `what's the difference between let and var in es6` or asks candidate to interpret a given code example in the beginning, in order to assess how much does a candidate master scope. + +[You Don't Know JS](https://github.com/getify/You-Dont-Know-JS) has a great explanation on scope. Here it is the TOC of the book, we recommend you to do some intensive reading. + +* Chapter 1: What is Scope? +* Chapter 2: Lexical Scope +* Chapter 3: Function vs. Block Scope +* Chapter 4: Hoisting +* Chapter 5: Scope Closures +* ... + +## Reference + +> In JavaScript, which types are pass by reference? And which types are pass by value? How to pass a variable by reference? + +Simply speaking, objects are pass by reference. Basic types are pass by value. We can pass basic types by reference using boxing technique. (More information at note 1) + +Pass by reference and pass by value is a basic question. It is fundamental part to understand how does JavaScript's memory work. It is hardly to have further discussion without understanding reference. + +In coding session, we use questions like `how to write a json object copy function` to assess candidate. + +Sometimes, we ask about the difference between `==` and `===`. And then, `true` or `false` of `[1] == [1]`. Without a good foundation, candidate may make a wrong conclusion because of the wrong understanding of `==` and `===`. + +Note 1: For senior candidates, you are expected to question directly on the question. e.g. There is no pass by reference in JavaScript. There is call by sharing. Read about [Is JavaScript a pass-by-reference or pass-by-value language?](http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language). Though it is advanced, it is common for senior developer with more than 3 years experiences. + +If C++ is mentioned in resume, it is certain to ask `what is the difference between pointer and reference`. From a48634589f3335bc8653ab092babbc7d29b0fe9f Mon Sep 17 00:00:00 2001 From: "soda.wang" Date: Sun, 24 Dec 2017 19:48:50 +0800 Subject: [PATCH 05/18] section: io, specify the console's situation --- sections/zh-cn/io.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/io.md b/sections/zh-cn/io.md index 701cacd..74240f2 100644 --- a/sections/zh-cn/io.md +++ b/sections/zh-cn/io.md @@ -199,7 +199,7 @@ pipe 方法最主要的目的就是将数据的流动缓冲到一个可接受的 ## Console -[console.log 正常情况下是异步的, 除非你使用 `new Console(stdout[, stderr])` 指定了一个文件为目的地](https://nodejs.org/dist/latest-v6.x/docs/api/console.html#console_asynchronous_vs_synchronous_consoles). 不过一般情况下的实现都是如下 ([6.x 源代码](https://github.com/nodejs/node/blob/v6.x/lib/console.js#L42)): +[console.log 同步还是异步取决于与谁相连和`os`](https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_a_note_on_process_i_o). 不过一般情况下的实现都是如下 ([6.x 源代码](https://github.com/nodejs/node/blob/v6.x/lib/console.js#L42)),其中`this._stdout`默认是`process.stdout`: ```javascript // As of v8 5.0.71.32, the combination of rest param, template string From 99de2564da20f0aaac1e8a61a940323daaf16a42 Mon Sep 17 00:00:00 2001 From: "soda.wang" Date: Sun, 24 Dec 2017 19:52:25 +0800 Subject: [PATCH 06/18] section: io, supplement of StringDecoder --- sections/zh-cn/io.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/io.md b/sections/zh-cn/io.md index 74240f2..2f4ae0a 100644 --- a/sections/zh-cn/io.md +++ b/sections/zh-cn/io.md @@ -65,7 +65,7 @@ const euro = Buffer.from([0xE2, 0x82, 0xAC]); console.log(decoder.write(euro)); // € ``` -当然也可以断断续续的处理. +stringDecoder.write 会确保返回的字符串不包含 Buffer 末尾残缺的多字节字符,残缺的多字节字符会被保存在一个内部的 buffer 中用于下次调用 stringDecoder.write() 或 stringDecoder.end()。 ```javascript const StringDecoder = require('string_decoder').StringDecoder; From 902ed73a7563fe92523bb36ceb09d9e5766c86f3 Mon Sep 17 00:00:00 2001 From: Lellansin Date: Fri, 19 Jan 2018 14:18:58 +0800 Subject: [PATCH 07/18] section: event-async, fix typo: https://github.com/ElemeFE/node-interview/issues/61 --- sections/zh-cn/event-async.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/event-async.md b/sections/zh-cn/event-async.md index cbc511e..08562f4 100644 --- a/sections/zh-cn/event-async.md +++ b/sections/zh-cn/event-async.md @@ -222,6 +222,6 @@ function sleep(ms) { 并行 (Parallel) = 2 队列对应 2 咖啡机. -Node.js 通过事件循环来挨个抽取事件队列中的一个个 Task 执行, 从而避免了传统的多线程情况下 `2个队列对应 1个咖啡机` 的时候上线文切换以及资源争抢/同步的问题, 所以获得了高并发的成就. +Node.js 通过事件循环来挨个抽取事件队列中的一个个 Task 执行, 从而避免了传统的多线程情况下 `2个队列对应 1个咖啡机` 的时候上下文切换以及资源争抢/同步的问题, 所以获得了高并发的成就. 至于在 node 中并行, 你可以通过 cluster 来再添加一个咖啡机. From 758e3aef39541f93cdd31287731a83a684bafb5f Mon Sep 17 00:00:00 2001 From: David Zhang Date: Fri, 23 Feb 2018 13:14:58 +0800 Subject: [PATCH 08/18] section: common, Translate Memory release & es6 features (#58) * Translate memory release & es6 features * Fix typos --- sections/en-us/common.md | 67 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/sections/en-us/common.md b/sections/en-us/common.md index 08c5269..8c0425c 100644 --- a/sections/en-us/common.md +++ b/sections/en-us/common.md @@ -3,8 +3,8 @@ * [`[Common]` Type judgment](/sections/en-us/common.md#Type-judgement) * [`[Common]` Scope](/sections/en-us/common.md#Scope) * [`[Common]` Reference](/sections/en-us/common.md#Reference) -* `[Common]` Memory release -* `[Common]` ES6+ features +* [`[Common]` Memory release](/sections/en-us/common.md#Memory-release) +* [`[Common]` ES6+ features](/sections/en-us/common.md#ES6-features) ## Summary @@ -46,3 +46,66 @@ Sometimes, we ask about the difference between `==` and `===`. And then, `true` Note 1: For senior candidates, you are expected to question directly on the question. e.g. There is no pass by reference in JavaScript. There is call by sharing. Read about [Is JavaScript a pass-by-reference or pass-by-value language?](http://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language). Though it is advanced, it is common for senior developer with more than 3 years experiences. If C++ is mentioned in resume, it is certain to ask `what is the difference between pointer and reference`. + +## Memory release + +> When will each types and each scope of variables be released in JavaScript? + +If reference was no longer referenced, it would be collected by the GC of V8. If a value variable was inside a closure, it wouldn't be release until the closure was no longer referenced. In non-closure scope, it will be collected when V8 is switched to new space. + +In contrast to frontend JavaScript, a Node.js developer with more than 2 years experience should care about memory. Though you may not understand in depth, you had better have a basic concept of memory release and start to pay attention to memory leaks. + +You need to know which operations lead to memory leaks, or even crash the memory. For example, will the code segment given below fill up with all of V8's memory? + +```javaScript +let arr = []; +while(true) + arr.push(1); +``` + +Then, what's the difference between this one and the above? + +```javaScript +let arr = []; +while(true) + arr.push(); +``` + +If a `Buffer` was pushed, what would happen? + +```javaScript +let arr = []; +while(true) + arr.push(new Buffer(1000)); +``` + +After thinking about the aboves, try to figure out what else can fill up with V8's memory. And then let's talk about memory leaks. + +```javaScript +function out() { + const bigData = new Buffer(100); + inner = function () { + void bigData; + } +} +``` + +Closure references variable from its parent. If it is not released, a memory leak happens. The example above shows `inner` is under the root, which causes a memory leak (`bigData` is not released). + +For senior candidates, you need to know the mechanism of GC in V8 and know how memory snapshot (which will be discussed in chapter of `Debug/Optimization`) works. e.g. Where do V8 store different types of data? What are the specific optimizing strategies for different areas when doing memory release? + +## ES6 features + +We recommend a [ECMAScript 6 Tutorial](http://es6.ruanyifeng.com/) book from @ruanyifeng (in Chinese). + +The basic questions can be the differences between `let` and `var`, and between `arrow function` and `function`. + +To go deeper, there are lots of details in es6, such as `reference` together with `const`. Talk about `Set` and `Map` in context of usage and disadvantages of `{}`. Or it can be about the privatization and `symbol`. + +However, it is unnecessary to ask `what is a closure?`. Instead, we'd like to ask about the application of closures. e.g. If interviewer usually uses closure to make data private, then we may ask can new features (e.g. `class` and `symbol`) be private? If true, then why we need closure here? When will data in a closure be released? And so on. + +For `...`, how to implement deletion of duplicated for an array (Bonus point for using Set). + +> Is it possible for an element in a const Array be modified? If possible, what's the effect of const? + +The elements can be modified. And it protects the reference, which cannot be modified (e.g. [Map](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map) is sensitive to reference and it need const. Besides, it is also suitable for immutable). From 144a8a060c2a33f600b696837ea0f89544910c10 Mon Sep 17 00:00:00 2001 From: Lellansin Date: Tue, 3 Apr 2018 02:07:00 +0800 Subject: [PATCH 09/18] fix: typos -> https://github.com/ElemeFE/node-interview/issues/66 --- sections/zh-cn/network.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/network.md b/sections/zh-cn/network.md index 17d6ff8..1142ffc 100644 --- a/sections/zh-cn/network.md +++ b/sections/zh-cn/network.md @@ -33,7 +33,7 @@ ***方案1*** -只需要等上一段时间再进行下一次 send 就好, 适用于交互频率特别低的场景. 缺点也很明显, 对于比较频繁的场景而言传输效率实在太低. 不过几乎用做什么处理. +只需要等上一段时间再进行下一次 send 就好, 适用于交互频率特别低的场景. 缺点也很明显, 对于比较频繁的场景而言传输效率实在太低. 不过几乎不用做什么处理. ***方案2*** From 9b48d89b51c2980c06af772e0c132a1f81366b35 Mon Sep 17 00:00:00 2001 From: sinchang Date: Thu, 12 Apr 2018 19:02:09 +0800 Subject: [PATCH 10/18] docs: fix background image (#68) closes #67 --- sections/en-us/README.md | 2 +- sections/zh-cn/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sections/en-us/README.md b/sections/en-us/README.md index efb06f8..5a704f2 100644 --- a/sections/en-us/README.md +++ b/sections/en-us/README.md @@ -1,4 +1,4 @@ -![ElemeFE-background](/assets/ElemeFE-background.png) +![ElemeFE-background](../../assets/ElemeFE-background.png) ## Guide diff --git a/sections/zh-cn/README.md b/sections/zh-cn/README.md index 7aad507..a564c04 100644 --- a/sections/zh-cn/README.md +++ b/sections/zh-cn/README.md @@ -1,4 +1,4 @@ -![ElemeFE-background](/assets/ElemeFE-background.png) +![ElemeFE-background](../../assets/ElemeFE-background.png) # 如何通过饿了么 Node.js 面试 From 0be68fdc91c4ab170e707aa0e07989fb7d81fc1e Mon Sep 17 00:00:00 2001 From: "Jinke.Li" <1359518268@qq.com> Date: Wed, 9 May 2018 13:57:10 +0800 Subject: [PATCH 11/18] section: event-async, fix typo (#70) --- sections/zh-cn/event-async.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/event-async.md b/sections/zh-cn/event-async.md index 08562f4..4a5b272 100644 --- a/sections/zh-cn/event-async.md +++ b/sections/zh-cn/event-async.md @@ -35,7 +35,7 @@ doSth.then(() => { }); ``` -毫无疑问的可以得到一下输出结果: +毫无疑问的可以得到以下输出结果: ``` hello From 0c2577f38a8efa7ac423bb63dbdaeea876f17c64 Mon Sep 17 00:00:00 2001 From: AlbertLee Date: Fri, 11 May 2018 16:03:25 +0800 Subject: [PATCH 12/18] section: security, fix typo: SLL => SSL (#71) --- sections/zh-cn/security.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/security.md b/sections/zh-cn/security.md index d9267ce..798f809 100644 --- a/sections/zh-cn/security.md +++ b/sections/zh-cn/security.md @@ -45,7 +45,7 @@ Node.js 的加密貌似有点问题, 某些算法算出来跟别的语言 (比 由 RA 统筹、审核用户的证书申请, 将证书申请送至 CA 处理后发出证书, 并将证书公告至 DS 中. 在使用证书的过程中, 除了对证书的信任关系与证书本身的正确性做检查外, 并透过产生和发布证书废止列表 (Certificate Revocation List, CRL) 对证书的状态做确认检查, 了解证书是否因某种原因而遭废弃. 证书就像是个人的身分证, 其内容包括证书序号、用户名称、公开金钥 (Public Key) 、证书有效期限等. -在 TLS/SLL 中你可以使用 OpenSSL 来生成 TLS/SSL 传输时用来认证的 public/private key. 不过这个 public/private key 是自己生成的, 而通过 PKI 基础设施可以获得权威的第三方证书 (key) 从而加密 HTTP 传输安全. 目前博客圈子里比较流行的是 [Let's Encrypt 签发免费的 HTTPS 证书](https://imququ.com/post/letsencrypt-certificate.html). +在 TLS/SSL 中你可以使用 OpenSSL 来生成 TLS/SSL 传输时用来认证的 public/private key. 不过这个 public/private key 是自己生成的, 而通过 PKI 基础设施可以获得权威的第三方证书 (key) 从而加密 HTTP 传输安全. 目前博客圈子里比较流行的是 [Let's Encrypt 签发免费的 HTTPS 证书](https://imququ.com/post/letsencrypt-certificate.html). 需要注意的是, 如果 PKI 受到攻击, 那么 HTTPS 也一样不安全. 可以参见 [HTTPS 劫持 - 知乎讨论](https://www.zhihu.com/question/22795329) 中的情况, 证书由 CA 机构签发, 一般浏览器遇到非权威的 CA 机构是会告警的 (参见 [12306](https://kyfw.12306.cn/otn/)), 但是如果你在某些特殊的情况下信任了某个未知机构/证书, 那么也可能被劫持. From b15f23c023fa5b2e4d938d62f0dd465a10b60f38 Mon Sep 17 00:00:00 2001 From: Roman Morozov <577222+sublimeye@users.noreply.github.com> Date: Wed, 30 May 2018 22:38:24 -0700 Subject: [PATCH 13/18] section: process, fix typo --- sections/en-us/process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/en-us/process.md b/sections/en-us/process.md index 29a54da..7dfadc1 100644 --- a/sections/en-us/process.md +++ b/sections/en-us/process.md @@ -27,7 +27,7 @@ For more details about the process and the operating system, you can read the AP ## Process -Here we will discuss the `project` object in Node.js. It can be printed out by using `console.log (process)` in the code. You can see the process object exposed a lot of useful properties and methods. For more details you can refer [Official document](https://nodejs.org/dist/latest-v6.x/docs/api/process.html), which has been very detailed, +Here we will discuss the `process` object in Node.js. It can be printed out by using `console.log (process)` in the code. You can see the process object exposed a lot of useful properties and methods. For more details you can refer [Official document](https://nodejs.org/dist/latest-v6.x/docs/api/process.html), which has been very detailed, including but not limited to: * The basic information of the process From f48365b601dd938131ea82d3bf9c929ac30d863a Mon Sep 17 00:00:00 2001 From: abhishek gupta Date: Mon, 16 Jul 2018 08:17:05 +0530 Subject: [PATCH 14/18] section: common, fix typo (#73) --- sections/en-us/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/en-us/README.md b/sections/en-us/README.md index 5a704f2..75241bd 100644 --- a/sections/en-us/README.md +++ b/sections/en-us/README.md @@ -15,7 +15,7 @@ **Common Problem** -[View more](/sections/en-us/js-basic.md) +[View more](/sections/en-us/common.md) ## [Module](/sections/en-us/module.md) From 719dd6041b302fb1fda150f7ce54e1c747c9eb0b Mon Sep 17 00:00:00 2001 From: KUI CHU Date: Fri, 10 Aug 2018 15:06:01 +0800 Subject: [PATCH 15/18] section: util.md, fix typo (#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 转移=》转义 --- sections/zh-cn/util.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/util.md b/sections/zh-cn/util.md index 70ef812..7be404e 100644 --- a/sections/zh-cn/util.md +++ b/sections/zh-cn/util.md @@ -24,7 +24,7 @@ ### 转义字符 -常见的需要转移的字符列表: +常见的需要转义的字符列表: |字符|encodeURI| |---|---| From 07853a751b518dcbfa994bce4a4aad43efa6baf5 Mon Sep 17 00:00:00 2001 From: kailunyao Date: Sun, 26 Aug 2018 20:57:00 -0500 Subject: [PATCH 16/18] section: network.md, fix typo (#75) --- sections/zh-cn/network.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/network.md b/sections/zh-cn/network.md index 1142ffc..efe1d15 100644 --- a/sections/zh-cn/network.md +++ b/sections/zh-cn/network.md @@ -16,7 +16,7 @@ 默认情况下, TCP 连接会启用延迟传送算法 (Nagle 算法), 在数据发送之前缓存他们. 如果短时间有多个数据发送, 会缓冲到一起作一次发送 (缓冲大小见 `socket.bufferSize`), 这样可以减少 IO 消耗提高性能. -如果是传输文件的话, 那么根本不用处理粘包的问题, 来一个包拼一个包就好了. 但是如果是多条消息, 或者是别的用途的数据那么久需要处理粘包. +如果是传输文件的话, 那么根本不用处理粘包的问题, 来一个包拼一个包就好了. 但是如果是多条消息, 或者是别的用途的数据那么就需要处理粘包. 可以参见网上流传比较广的一个例子, 连续调用两次 send 分别发送两段数据 data1 和 data2, 在接收端有以下几种常见的情况: From 9852022b0a70c41450ef17e054fdecc5d8d47f1b Mon Sep 17 00:00:00 2001 From: Oleg Stotsky Date: Tue, 9 Oct 2018 12:27:14 +1000 Subject: [PATCH 17/18] section: Error handle & Debug, fix typo (#77) --- sections/en-us/error.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/en-us/error.md b/sections/en-us/error.md index c36bde0..1c69be4 100644 --- a/sections/en-us/error.md +++ b/sections/en-us/error.md @@ -231,7 +231,7 @@ You can see the latest news about this module at: [deprecate domains](https://gi Command line debug tool like gdb (Build-in debugger in the image above), it also supports remote debug (like [node-inspector](https://github.com/node-inspector/node-inspector), but still in trial). Of course, many developers feel that [vscode](https://code.visualstudio.com/) has maken a better integration to the debug tools. -We recommend reading [official ducoment](https://nodejs.org/dist/latest-v6.x/docs/api/debugger.html) to learn how to use this build-in debugger. If you want to dig deeper, see: [Modify the value of a variable in the NodeJS program dynamically](http://code.oneapm.com/nodejs/2015/06/27/intereference/) +We recommend reading [official document](https://nodejs.org/dist/latest-v6.x/docs/api/debugger.html) to learn how to use this build-in debugger. If you want to dig deeper, see: [Modify the value of a variable in the NodeJS program dynamically](http://code.oneapm.com/nodejs/2015/06/27/intereference/) ## C/C++ Addon From 59de80b63ddd359e9d85fb25b162bef62c250389 Mon Sep 17 00:00:00 2001 From: ZYSzys Date: Mon, 26 Nov 2018 12:00:31 +0800 Subject: [PATCH 18/18] section: correct module require cycle (#79) --- sections/zh-cn/module.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/zh-cn/module.md b/sections/zh-cn/module.md index d7d69b8..5db7128 100644 --- a/sections/zh-cn/module.md +++ b/sections/zh-cn/module.md @@ -64,7 +64,7 @@ function require(...) { > a.js 和 b.js 两个文件互相 require 是否会死循环? 双方是否能导出变量? 如何从设计上避免这种问题? -② 不会, 先执行的导出空对象, 通过导出工厂函数让对方从函数去拿比较好避免. 模块在导出的只是 `var module = { exports: {} };` 中的 exports, 以从 a.js 启动为例, a.js 还没执行完 exports 就是 `{}` 在 b.js 的开头拿到的就是 `{}` 而已. +② 不会, 先执行的导出其 **未完成的副本**, 通过导出工厂函数让对方从函数去拿比较好避免. 模块在导出的只是 `var module = { exports: {...} };` 中的 exports, 以从 a.js 启动为例, a.js 还没执行完会返回一个 a.js 的 exports 对象的 **未完成的副本** 给 b.js 模块。 然后 b.js 完成加载,并将 exports 对象提供给 a.js 模块。 另外还有非常基础和常见的问题, 比如 module.exports 和 exports 的区别这里也能一并解决了 exports 只是 module.exports 的一个引用. 没看懂可以在细看我以前发的[帖子](https://cnodejs.org/topic/5734017ac3e4ef7657ab1215).