What is the output?
Anonymous Quiz
30%
default hello true
30%
default default true
28%
hello default true
12%
hello default false
🤣3🔥2
CHALLENGE
function Timer() {
this.seconds = 0;
this.tick = () => { this.seconds++; };
this.tickRegular = function () { this.seconds++; };
}
const t = new Timer();
const { tick, tickRegular } = t;
tick();
let regularResult;
try {
tickRegular();
regularResult = 'no error';
} catch (e) {
regularResult = e instanceof TypeError;
}
console.log(t.seconds, regularResult);❤4👍1
🔥5
CHALLENGE
const a = [] + [];
const b = [] + {};
const c = {} + [];
const d = 1 + "1" - 1;
console.log(a, b, c, d);
🔥2🤔2🤩1
CHALLENGE
let count = 0;
const inc = () => (count += 1, count);
const a = 0 || inc();
const b = null ?? inc();
const c = a && inc();
const d = b?.toString() || inc();
console.log(a, b, c, d, count);
❤3👍2
👍4🔥3
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);
❤2🔥2
What is the output?
Anonymous Quiz
33%
35 [ 20, <1 empty item>, 40, NaN, 60 ]
30%
35 [ 20, 0, 40, NaN, 60 ]
14%
35 [ NaN, 20, 40, 60 ]
23%
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);
❤3
What is the output?
Anonymous Quiz
26%
k0,k1,k2 0 1 2
27%
k0,k1,k2 1 1 1
33%
k1,k2,k3 1 2 3
15%
k0,k1,k2 1 2 3
❤6
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);
What is the output?
Anonymous Quiz
18%
1 7 -6 2147483648 15 0
35%
1 7 -6 -2147483648 15 5
32%
1 7 -6 -2147483648 15 0
16%
1 7 -5 -2147483648 15 0
❤3🤔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);
}
❤2
What is the output?
Anonymous Quiz
31%
ReferenceError undefined
32%
TypeError undefined
24%
undefined undefined
14%
TypeError object
❤4
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
28%
string number1 512 33 true false
29%
string 1number 512 33 true false
15%
number number 512 33 true true
❤3
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);❤2
What is the output?
Anonymous Quiz
16%
5 5 false true
41%
10 5 true true
26%
10 5 false true
17%
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);❤5👍1🤔1