Promise chain call, exception penetration and interrupt promise chain
promise. Parameters of then()
. then is a method on promise prototype, which returns a promise object, which can accept two callback parameters: 1 onResolved, 2. Onrejected, these two parameters have one parameter respectively, which is the data of successful execution and the data of failed execution. In fact, the first callback function ...
Added by dodgeqwe on Fri, 31 Dec 2021 06:52:55 +0200
es6 deconstruction assignment
1, Deconstruction and assignment of variables
1. Deconstruction assignment of object
(1) The property name is inconsistent with the variable name When the attribute name is inconsistent with the variable name, you need to explicitly specify the attribute name. In this way, the attribute value can be assigned to the variable.
let user = {name ...
Added by kkibak on Wed, 29 Dec 2021 13:09:37 +0200
sinon. spy, stub and mock of JS
sinon As you know, in Java unit testing, when you can't get the actual object, we can use Mock/Stub to mock our code, which is more convenient for us to test.
EasyMock, JMock and Mockito can solve these problems. The concepts of spy, stub and mock are introduced. Similarly, we will encounter similar situations in front-end testing. Sinon.js is ...
Added by gokhul on Tue, 28 Dec 2021 12:29:23 +0200
You must know the iterator and generator
generator is a special iterator, which can replace the implementation of iterator to make the code more conciseWhat is an iteratorAn iterator is called an iterator. It is an object used to help traverse a data structure. This object needs to comply with the iterator protocol.The iterator protocol requires the implementation of the next method, ...
Added by scott56hannah on Tue, 28 Dec 2021 01:35:14 +0200
Publish Subscription Mode EventEmitter
Node. The events module of JS provides an external EventEmitter object for Node. Events in JS are managed uniformly. Because Node.js uses event-driven mechanisms, and EventEmitter is Node.js implements the foundation of event driven. On the basis of EventEmitter, Node. Almost all modules in JS inherit this class to implement an asynchronous eve ...
Added by ljschrenk on Mon, 27 Dec 2021 19:57:16 +0200
ES6 ES6 Latest Proposal, do, throw, partial function execution, pipeline operator |>, Curitization,:, Realm API
ES6 (29) ES6 latest proposal, do, throw, partial function execution, pipeline operator |>, Curitization,:, Realm API
1. do expression
Essentially, a block-level scope is a statement that encapsulates multiple operations together with no return value.
{
let t = f();
t = t * t + 1;
}
In the code above, the block-level scope encaps ...
Added by php new bie on Mon, 27 Dec 2021 08:19:49 +0200
JavaScript advanced part-03 (this point / context execution mode / recursion / closure)
1.this point
Function has three execution modes: global function, object method and constructorthis: I point to whoever calls me (independent of the function declaration, depending on the function call)
Global function: function name () -------------- > this points to windowObject method: object name Method name () ---- -- > this poi ...
Added by wombatee on Mon, 27 Dec 2021 08:08:34 +0200
js array sorting and Sort method
Time complexity & space complexityIt can be seen from the figure that the time complexity should be controlled below O(nlogn).Space complexity is a measure of the amount of storage space temporarily occupied by an algorithm during operationAccording to their characteristics, js sorting can be roughly divided into two types: comparison sort ...
Added by bjoerndalen on Fri, 24 Dec 2021 04:21:00 +0200
Several methods of javaScript array traversal and the processing of sparse arrays
brief introduction
array traversal method is also called array iterator method. Iterator is a software design pattern in programming. In js, we can use it to traverse the array without paying attention to the details of its internal implementation. the following traversal methods will not affect the original array, th ...
Added by adrian_melange on Wed, 22 Dec 2021 07:55:17 +0200
Wechat applet learning journey -- improving the pages page -- Font Icon, data binding, condition / list rendering, event / catch/bind and routing learning
Previously:
Wechat applet learning journey - production of the first page
Wechat applet learning journey - making your own applet based on zero - making the second page
Introduction to wechat applet (3)
We made the article section earlier.
The simulated user collection articles and browsing times we made at that time used png format ...
Added by astaroth on Wed, 22 Dec 2021 06:04:58 +0200