I joined the new company in June and was fortunate to participate in the technology stack training provided by the company.
Although I don’t usually like learning very much, and my technical foundation is weaker than my kidneys, but after all, I have been around for 5 years, and basically I have understood or experienced almost all of them. So I didn't panic at first, but from the first class, I was shocked - I always knew that I was good at it, but I didn't expect that I was so good at it!
Here are some tidies:
About node.js
1. The priority and uniqueness of require loading files: I only know that it will not be loaded twice, and our customized files are all in the form of ("./***"), and I don't know about the others.
require加载文件的优先级以及唯一性
如果是名称,优先级 文件模块缓存->内置模块->第三方模块(node_modules)
如果是路径,则会按照自定义模块的规则查找。require("./a"); a->a.js->a.json->a.node->a文件夹(package.json mian指定 没有则index)
每一个编译成功的模块都会将其文件路径作为索引缓存在Module._cache对象上,以提高二次引入的性能。(深入浅出node.js p15-p20)
调用module.load()读取模块内容,然后调用modele.compile()编译执行
2. The characteristics of the arrow function: I only know that this cannot be
没有自身的this,函数体内的this,指向定义时的对象,而不是使用时的对象
不能当作构造函数,不能使用new命令
不能使用arguments对象,可以使用rest参数代替
不可使用yield命令,因此箭头函数不能用作Generator
3. Block-level scope
arr = [];
let i;
for (i = 1; i < 10; i++) {
arr.push(function () {
console.log(i);
});
}
arr.forEach((func) => func()); //10,10,10,10,10,10,10,10,10
arr = [];
for (let i = 1; i < 10; i++) {
arr.push(function () {
console.log(i);
});
}
arr.forEach((func) => func()); //1,2,3,4,5,6,7,8,9
arr = [];
for (let a = []; a.length < 10; a.push(a.length)) {
arr.push(function () {
console.log(a.length);
});
}
arr.forEach((func) => func()); //10,10,10,10,10,10,10,10,10
This problem has troubled me for a long time.
https://es6.ruanyifeng.com/#docs/let take a look at this website
The explanation in Ruan Yifeng's article is that each cycle is a new variable, but this statement cannot explain the phenomenon of arrays. So the variable is still the same variable, but when the basic type is assigned, it will be converted into a constant value for processing. The types such as arrays and objects still refer to the original pointer.
about http
Re-learned and sorted out the body's too long processing mechanism, port multiplexing, cross-domain and other knowledge. Here's an interesting little episode
The difference between the get and the post we are talking about ! ! !
I don't know when I saw this post and was attracted by his emoji at the end of the post. So he remembered what he said- GET generates a TCP packet; POST generates two TCP packets.
When the mentor asked me, I answered this confidently, but, I feel that my mentor looked at me like I was mentally retarded ==!
Later I saw other related articles
https://zhuanlan.zhihu.com/p/25028045
https://blog.josephscott.org/2009/08/27/xmlhttprequest-xhr-uses-multiple-packets-for-http-post/
So these are the design processing mechanisms of different browsers or the server itself, including other things that we say get data, urlpost, body, etc. cannot be called differences.
So what is the difference? I found the ultimate answer - different names .
About mongodb and index optimization
It mainly explains the process of analyzing query execution, including b-tree, b+-tree, composite index, etc.
Mongo's sparse index is different from others. Mongo's sparse index (sparse) refers to the entries of documents that only contain index fields, and skips documents that do not have index keys. The sparse index we often say is interval, which is different from dense Index relative.
About framework development and unit testing
log4j log format configuration, the config module manages the operating environment version, and thenjs, which is different from await, controls the asynchronous process
The focus is to learn the knowledge and application of mocha coverage report supertest to simulate network requests and other unit tests.
If the child route wants to get the value of the parent route, you can use const router = express.Router({ mergeParams: true });