main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"use strict";

function promiseSqrt(value){
    console.log('START execution with value =', value);
    return new Promise(function (fulfill, reject){
        setTimeout(function() {
            fulfill({ value: value, result: value * value });
        }, 0 | Math.random() * 100);
    });
}

promiseSqrt(2).then(function(obj) {
    console.log('END execution with value =', obj.value, 'and result =', obj.result);
});
console.log('COMPLETED ?');
Native Browser JavaScript