1. Prototypes: Objects Inherit from Other Objects
2. Functions Are Independent Units of Behavior
Functions can be declared in the global scope or identified as independent units that can be reused within a module.
3. IIFE, i.e., Immediately Invoked Function Expression
Immediately Invoked Function Expression is a function called immediately after its creation.
An example of defining an IIFE is:
(() => console.log(‘Hello world’))();
The outside world can't retrieve variables declared within the IIFE. It prevents the global scope from becoming polluted. Therefore, the key reason for using IIFE is to execute the code immediately and achieve data privacy.
4. A Single-Threaded Language
In the main thread, two functions cannot run simultaneously. You may have heard of options for running different functions parallelly, such as web workers, but workers do not share information with the main thread. They just communicate by passing messages; nothing is shared. This simplifies things, and we only need to focus on making functions run quickly. A long-running function will cause the page to become unresponsive.
This is automatic; hence, a closure is created each time a callback function is created, or a function is returned for another function. These closures are important because they can be used for asynchronous programming.
Frequently Asked Questions
4. Rich Interfaces
1. Light-Weight Language
4. Control Statements Equipped
5. Dynamic Typing
Enjoy the benefits of a freelance license and visa, such as a Work Permit, Emirates ID, Residency, and Option to Sponsor Family.