CHALLENGE
const arr = [1, [2, 3], [4, [5, 6]], 7];
const a = arr.flat();
const b = arr.flat(2);
const c = arr.flatMap(x => Array.isArray(x) ? x : [x, x]);
const d = [1, 2, 3].flatMap(x => [[x]]);
console.log(JSON.stringify([a, b, c, d]));
What is the output?
Anonymous Quiz
21%
[[1,2,3,4,[5,6],7],[1,2,3,4,5,6,7],[1,1,2,3,4,[5,6],7,7],[1,2,3]]
38%
[[1,2,3,4,[5,6],7],[1,2,3,4,5,6,7],[1,1,2,3,4,[5,6],7,7],[[1],[2],[3]]]
33%
[[1,2,3,4,5,6,7],[1,2,3,4,5,6,7],[1,1,2,3,4,[5,6],7,7],[[1],[2],[3]]]
8%
[[1,2,3,4,[5,6],7],[1,2,3,4,5,6,7],[1,1,2,3,4,5,6,7,7],[[1],[2],[3]]]
👍1
CHALLENGE
const source = {
_val: 1,
get val() { return this._val; }
};
const copy1 = Object.assign({}, source);
source._val = 100;
const copy2 = { ...source };
copy1._val = 999;
console.log(copy1.val, copy2.val, source.val, copy1._val);❤2🔥1
What is the output?
Anonymous Quiz
22%
1 100 1 999
37%
1 100 100 999
33%
100 100 100 999
8%
1 1 100 999
❤1