While familiarizing myself with Promises in Javascript through a tutorial, I noticed the use of the then() method in various instances.
Upon writing the code below, I stumbled upon the "then()" function within the __proto__ section of the console:
const myPromise = new Promise(function(resolve, reject) {});
console.log(myPromise);
However, when I wrote the following code for a car class, I did not see the "then()" function present:
class Car {
constructor(color, type, doors) {
this.color = color;
this.type = type;
this.doors = doors
}
}
const myCar = new Car('blue', 'sedan', '4');
console.log(myCar);
This raised an intriguing question in my mind: Is it possible to create our own custom then()
function in Javascript and run it?