function Test() {
this.run = function() {
console.log('run', this);
setTimeout(this.run, 1000);
}
}
const t = new Test();
t.run();
for (var i = 0; i < 10; i++) {
setTimeout(function () {
console.log(i);
}, 1000);
}
F.of(1)
.add(2)
.mul(3)
.map(x => console.log(x))
new Promise((resolve, reject) => {
console.log('A');
resolve();
console.log('B');
})
.then(() => {
console.log('C');
});
console.log('D');
setTimeout(() => console.log('E'), 0);
process.nextTick(() => console.log('F'));
const a = [1, 3, 5];
const b = [2, 4, 6];
const c = f(a, b); // [1, 2, 3, 4, 5, 6];
console.log(['1', '2', '3'].map(parseInt));
console.log(f(10)); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
function isOdd(num) {
return num % 2 == 1;
}
function isEven(num) {
return num % 2 == 0;
}
function isSane(num) {
return isEven(num) || isOdd(num);
}
var values = [7, 4, '13', -9, Infinity];
values.map(isSane);