Javascript
Schedular API

Schedular API

The browser does not support setImmediate method which helps us to chunk the codes(taking the long task that is breaking the main thread into smaller pieces by which the main thread can perform operations between those chunks).

Since this isn't available in browser we overcome this issue with the use of schedular API.

 
function blockingExample () {
    console.time('blocking task');
 
    let sum = 0;
    for (let i = 0; i < 10000000000, i++) {
        sum += i;
    }
    console.timeEnd('blocking complete');
    console.log(sum);
}
 
blockingExample();