JavaScript
How JS works?
There are three components:
- Call stack
- Message queue
- Event loop
Event loop waits for a messages to arrive in the Message queue
. The messages are processed in FIFO order, that's why it's called Message queue
.
Prototypes
// Create an object
const MyObject = function () {};
// Add a property
MyObject.prototype.func1 = function () {};
// Use the property
const myObject = new MyObject();
myObject.func1();