Script may not execute in sequence and execution might happen randomly.
In order to solve this problem we incorporate the promise concept.
Promise Concept: A promise is a method / pattern to resolve asynchronous problem in JS.
Promise states are: Pending, Resolved & Rejected.
Synchronous: JS will move to next step only if promise of current existing step is in state Resolved or Rejected.
Asynchronous: JS moves to next step irrespective of state even if promise is pending.
Most of the Protractor methods resolve the promise but there are certain exceptions like retrieving data from web-browser eg: getText() for any field from web-browser where promise needs to be resolved manually.
There are 2 methods to resolve Asynchronous:
1. Using promise chaining via then() function
2. Using async and await