All quizzesMedium
Tricky Outputs — Series 3
Preview — 3 of 10 questions
What is logged?
javascript
const o = Object.seal({ a: 1, nested: { b: 2 } });
o.a = 9;
delete o.a;
o.nested.b = 9;
o.c = 1;
console.log(o.a, o.nested.b, 'c' in o, Object.isSealed(o));A9 9 false true
B1 2 false true
C9 9 true true
Dundefined 9 false true
What is logged?
javascript
const n = [1, 5, 10, 2];
const bad = [...n].sort((a, b) => a > b);
const good = [...n].sort((a, b) => a - b);
console.log(bad.join(','), good.join(','));A1,2,5,10 and 1,2,5,10
B10,5,2,1 and 1,2,5,10
C1,5,10,2 and 1,2,5,10
D1,10,2,5 and 1,2,5,10
What is logged?
javascript
const tag = (s, ...v) => s.raw.join('|') + '#' + v.join(',');
console.log(tag`a\nb${1}c${2}`);Aa<newline>b|c|#1,2
Ba\nb|c|#1,2
Ca\nb|c|1,2#
Da\nbc#12
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.