CHALLENGE
const nums = [1, 2, 3, 4, 5];
const result = nums
.filter(n => n % 2 !== 0)
.map(n => n ** 2)
.reduce((acc, n) => acc + n, 0);
const arr = [10, , 20, undefined, 30];
const mapped = arr.map(x => x * 2);
console.log(result, mapped);
🔥3❤2
What is the output?
Anonymous Quiz
31%
35 [ 20, <1 empty item>, 40, NaN, 60 ]
30%
35 [ 20, 0, 40, NaN, 60 ]
14%
35 [ NaN, 20, 40, 60 ]
25%
35 [ 20, undefined, 40, NaN, 60 ]
CHALLENGE
let i = 0;
const key = () => `k${i++}`;
const obj = {
[key()]: i,
[key()]: i,
[key()]: i,
};
console.log(Object.keys(obj).join(','), obj.k0, obj.k1, obj.k2);
❤4👍1
What is the output?
Anonymous Quiz
25%
k0,k1,k2 0 1 2
30%
k0,k1,k2 1 1 1
32%
k1,k2,k3 1 2 3
13%
k0,k1,k2 1 2 3
❤7
CHALLENGE
const a = 5 & 3;
const b = 5 | 2;
const c = ~5;
const d = 1 << 31;
const e = -1 >>> 28;
const f = 5 ^ 5;
console.log(a, b, c, d, e, f);
❤2
What is the output?
Anonymous Quiz
18%
1 7 -6 2147483648 15 0
36%
1 7 -6 -2147483648 15 5
29%
1 7 -6 -2147483648 15 0
17%
1 7 -5 -2147483648 15 0
❤4🤔3
CHALLENGE
'use strict';
function getValue() {
return this.value;
}
const obj = { value: 42, getValue };
const fn = obj.getValue;
try {
fn();
} catch (err) {
console.log(err.constructor.name, typeof this);
}
❤3
What is the output?
Anonymous Quiz
29%
ReferenceError undefined
29%
TypeError undefined
26%
undefined undefined
16%
TypeError object
❤5
CHALLENGE
console.log(
typeof typeof 1,
1 + typeof 1,
2 ** 3 ** 2,
1 + 2 + '3',
1 < 2 < 3,
3 > 2 > 1
);
🔥2
What is the output?
Anonymous Quiz
29%
string 1number 512 33 true true
26%
string number1 512 33 true false
27%
string 1number 512 33 true false
18%
number number 512 33 true true
❤4
CHALLENGE
function Foo(x) {
this.x = x;
return { x: x * 2 };
}
function Bar(x) {
this.x = x;
return 42;
}
const f = new Foo(5);
const b = new Bar(5);
console.log(f.x, b.x, f instanceof Foo, b instanceof Bar);❤5
What is the output?
Anonymous Quiz
18%
5 5 false true
37%
10 5 true true
29%
10 5 false true
16%
10 42 false true
CHALLENGE
function* inner() {
yield 1;
yield 2;
return 100;
}
function* outer() {
const result = yield* inner();
yield result;
yield 3;
}
const it = outer();
console.log(it.next().value, it.next().value, it.next().value, it.next().value);❤6👍4🤔2
What is the output?
Anonymous Quiz
23%
1 2 100 3
48%
1 2 100 undefined
20%
1 2 3 undefined
8%
1 2 undefined 3
❤2
I built an app with this and was impressed. You get a txiki.js-powered backend with full system access (including FFI!), native webview rendering, and tiny macOS, Linux, and Windows builds. It even makes it easy to sign/notarize the final app.
Tarwin Stroh-Spijer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤8👍3
CHALLENGE
class Base {
static count = 0;
static increment() {
this.count++;
return this.count;
}
}
class Derived extends Base {
static count = 10;
}
console.log(Base.increment(), Derived.increment(), Base.count, Derived.count);❤3
❤3🔥2👍1
CHALLENGE
let counter = 0;
const mod = {
get counter() { return counter; },
increment() { counter++; }
};
const { counter: snapshotCounter } = mod;
mod.increment();
mod.increment();
console.log(snapshotCounter, mod.counter, counter);
🔥4❤2
🤣2❤1🔥1
CHALLENGE
const obj = {
value: 42,
getValue() { return this?.value; },
getValueArrow: () => this?.value
};
const { getValue, getValueArrow } = obj;
console.log(obj.getValue(), getValue(), obj.getValueArrow(), getValueArrow());❤1