This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
var regeneratorRuntime = require("regenerator-runtime");
// var s = 1;
// function bar() {
// s = 3;
// }
// async function foo() {
// s = 2;
// bar();
// foo2();
// }
// async function foo2() {
// await (() => Promise.resolve(() => {
// s = 4;
// }))();
// }
// (async () => {
// await foo();
// console.log(s);
// })()
"use strict";
var s = 1;
function bar() {
s = 3;
}
function foo() {
return regeneratorRuntime.async(function foo$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
s = 2;
bar();
foo2();
case 3:
case "end":
return _context.stop();
}
}
});
}
function foo2() {
return regeneratorRuntime.async(function foo2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return regeneratorRuntime.awrap(function () {
return Promise.resolve(function () {
s = 4;
});
}());
case 2:
case "end":
return _context2.stop();
}
}
});
}
(function _callee() {
return regeneratorRuntime.async(function _callee$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return regeneratorRuntime.awrap(foo());
case 2:
console.log(s);
case 3:
case "end":
return _context3.stop();
}
}
});
})();