@todojs/

2.-ejecuciona-asincrona-natural

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.39849681239166923","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"InVzZSBzdHJpY3QiOw0KDQpmdW5jdGlvbiBhc3luY1NxcnQodmFsdWUsIGNhbGxiYWNrKSB7DQogICAgY29uc29sZS5sb2coJ1NUQVJUIGV4ZWN1dGlvbiB3aXRoIHZhbHVlID0nLCB2YWx1ZSk7DQogICAgc2V0VGltZW91dChmdW5jdGlvbigpIHsNCiAgICAgICAgY2FsbGJhY2sodmFsdWUsIHZhbHVlICogdmFsdWUpOw0KICAgIH0sIDAgfCBNYXRoLnJhbmRvbSgpICogMTAwKTsNCn0NCg0KZm9yICh2YXIgbiA9IDA7IG4gPCAxMDsgbisrKSB7DQogICAgYXN5bmNTcXJ0KG4sIGZ1bmN0aW9uKHZhbHVlLCByZXN1bHQpIHsNCiAgICAgICAgY29uc29sZS5sb2coJ0VORCBleGVjdXRpb24gd2l0aCB2YWx1ZSA9JywgdmFsdWUsDQogICAgICAgICAgICAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICB9KTsNCn0NCmNvbnNvbGUubG9nKCdDT01QTEVURUQgPycpOw=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"use strict";

function asyncSqrt(value, callback) {
    console.log('START execution with value =', value);
    setTimeout(function() {
        callback(value, value * value);
    }, 0 | Math.random() * 100);
}

for (var n = 0; n < 10; n++) {
    asyncSqrt(n, function(value, result) {
        console.log('END execution with value =', value,
            'and result =', result);
    });
}
console.log('COMPLETED ?');
Native Browser JavaScript