The 0. If the value is a promise, that promise is returned; if the value is a , Promise.resolve() will call the 2 method with two callbacks it prepared; otherwise the returned promise will be fulfilled with the value. Show This function flattens nested layers of promise-like objects (e.g. a promise that fulfills to a promise that fulfills to something) into a single layer — a promise that fulfills to a non-thenable value.
3Argument to be resolved by this 0. Can also be a 0 or a thenable to resolve.A 0 that is resolved with the given value, or the promise passed as value, if the value was a promise object. A resolved promise can be in any of the states — fulfilled, rejected, or pending. For example, resolving a rejected promise will still result in a rejected promise.
0, and the result will be a promise of the subclass type. To do so, the subclass's constructor must implement the same signature as the 1 constructor — accepting a single 2 function that can be called with the 3 and 4 callbacks as parameters.
0 instances. If 3 belongs to 0 or a subclass, and 9, then 3 is directly returned by Promise.resolve() , without creating a new 0 instance. Otherwise, Promise.resolve() is essentially a shorthand for 4.The bulk of the resolving logic is actually implemented by the passed by the 1 constructor. In summary:
0 instances. If it's resolving a native promise, it returns the same promise instance without creating a wrapper.
The inverted order of the logs is due to the fact that the 6 handlers are called asynchronously. See the 2 reference for more information.
Nested thenables will be "deeply flattened" to a single promise.
Warning: Do not call
1 constructor. For example, we can call it on a constructor that passes it 6 as 3:
The ability to flatten nested thenables is implemented by the resolver function of the 1 constructor, so if you call it on another constructor, nested thenables may not be flattened, depending on how that constructor implements its resolver.
Apa Itu Promise di javascript?Promise merupakan salah satu fitur yang penting dari ES6. Objek promise mewakili penyelesaian atau sebuah kesalahan pada operasi Asynchronous.
Kapan kita menggunakan asynchronous?Proses asynchronous sering digunakan untuk komunikasi data, karena data menjadi bagian inti dari sebuah aplikasi maka konsep asynchronous sangat penting untuk dipahami.
Apa itu synchronous dan asynchronous pada javascript?Definisi synchronous adalah sebuah operasi akan dijalankan setelah operasi sebelumnya selesai dijalankan alias berurutan. Sedangkan asynchronous sebaliknya, asynchronous tidak perlu menunggu operasi sebelumnya selesai untuk mengeksekusi operasi setelahnya.
Apa itu async Await Javascript?Async/await adalah fitur yang hadir sejak ES2017. Fitur ini mempermudah kita dalam menangani proses asynchronous.Async/Await merupakan sebuah syntax khusus yang digunakan untuk menangani Promise agar penulisan code lebih efisien dan rapih.
|