@championswimmer Something like this in India would be wild. A ginormous chunk of the ‘paper work’ bureaucracy layer which just sits to feast on the tax money could be shown some much needed spotlight.
@hannahsox12 The distinction boils down to looking through the product lens, thinking in systems, keeping the team unblocked and maintaining a healthy code base.
@ojhabhumika28 Function A will be faster as promises chained with a .then() won't block the main thread unlike function B which will wait for every prior promise to resolve before moving on.
@haider1 Object.assign() creates a shallow copy of the object “a” into an empty object and assigns it to “b”. We then change the value at “b.x” to 4 and upon logging, result in 1 and 4.
@ojhabhumika28 The code execution breaks over to the catch block when the code in the try block encounters an error resulting in 1 being logged followed by 2 as the statement in the finally block always gets executed.
@ojhabhumika28 As callAsync() gets invoked, it logs 1, sees the Promise keyword and sends it to the task queue for resolution and continues with the synchronous execution followed by printing 2. Finally prints 3 from the promise resolution as it gets popped off the task queue.
@chriskalmar It’s one of those tiny things which make the code appear much more easier to go through along with proper indentation and standard casing.
@ojhabhumika28 Any number of .then()'s can be attached to a promise so technically it should still print out 'Done', though it makes sense for a .then() to return a promise or a resolution for it to be useful.
Excited for your next set of topic or such pop-quizzes!
@ojhabhumika28 The frist block will log 20. In the second block, since arrow functions don't implicitly return when used with curly braces, res property on lines 9 and 11 will be undefined resulting in undefined being logged.
@ojhabhumika28 Promise.any() returns the first resolved promise from the array whereas Promise.race() returns the first promise which gets either resolved or rejected. The output to this should be “any-resolve quick” followed by “race-resolve 0”