Angular 🇺🇦 - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
🚳 Interview Questions: Implement promise.all method

#js #interview #promise

Analysis: Use the Promise.all principle to synchronize the Promise state through the counter and result array.
Please open Telegram to view this post
VIEW IN TELEGRAM
📵 Interview Questions: Implement Instanceof

#js #interview #instanceof

The instanceof operator in JavaScript can be used to determine whether an object is an instance of another object. However, the instanceof operator has some limitations, such as:

🥫The instanceof operator can only determine objects directly connected to the prototype chain.
🌯The instanceof operator cannot detect objects with cyclic prototype chains.
Therefore, the above code provides a more general instanceof function that can determine the relationship between any two objects.

The implementation principle of this function is:

🍗The function instanceof receives two parameters: left and right.
🥞First, the code checks to see if the number of parameters is 2, and if not, throws an error.
🥚Next, the code checks whether the left operand left is null. If so, it returns false directly, because null cannot be an instance of any object.
🧀Then, the code checks whether the type of the left operand left is an object. If not, it returns false directly, because only objects can be instances of the constructor.
🥖Next, the code uses Object.getPrototypeOf() to obtain the prototype of the left operand left and assigns it to the variable proto.
🍞In a loop, the code continues to traverse proto’s prototype chain until proto is null.
🥐In the loop, the code checks whether the prototype of the right operand right is equal to the current proto. If they are equal, it means that the left operand left is an instance of the right operand right and returns true.
🍠If no matching prototype is found at the end of the loop, that is, proto is null, it means that the left operand left is not an instance of the right operand right, and false is returned.
Please open Telegram to view this post
VIEW IN TELEGRAM
🚱 Interview Questions: Implement a debounce anti-shake function

#js #interview #debounce
Please open Telegram to view this post
VIEW IN TELEGRAM
📵 Exploring the New JavaScript Feature: Records and Tuples

#js #records #tuples

⚠️ ECMAScript® 2024 (ES15)

Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
1🔥1
📵 Create a Cancellable Promise

#js #promise

Create a cancellable promise P with a method cancel such that after we call the method P.cancel(), the promise cannot be resolved now. There should be a way to know that the promise was cancelled and not rejected.


Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
1
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM