Daily JavaScript
15 subscribers
1 photo
1 link
Daily examples, coding challenges, and useful tips for developers.
Download Telegram
40. What's the output?

[[0, 1], [2, 3]].reduce(
(acc, cur) => {
return acc.concat(cur);
},
[1, 2],
);
41. What's the output?

!!null;
!!'';
!!1;
42. What does the setInterval method return in the browser?

setInterval(() => console.log('Hi'), 1000);
Anonymous Quiz
100%
A: a unique id
0%
B: the amount of milliseconds specified
0%
C: the passed function
0%
D: undefined
44. What's the output?

function* generator(i) {
yield i;
yield i * 2;
}

const gen = generator(10);

console.log(gen.next().value);
console.log(gen.next().value);
44. What's the output?

Javob variantlari:
Anonymous Quiz
0%
A: [0, 10], [10, 20]
0%
B: 20, 20
100%
C: 10, 20
0%
D: 0, 10 and 10, 20
45. What does this return?

const firstPromise = new Promise((res, rej) => {
setTimeout(res, 500, 'one');
});

const secondPromise = new Promise((res, rej) => {
setTimeout(res, 100, 'two');
});

Promise.race([firstPromise, secondPromise]).then(res => console.log(res));
45. What does this return?

Javob variantlari:
Anonymous Quiz
0%
A: "one"
100%
B: "two"
0%
C: "two" "one"
0%
D: "one" "two"
46. What's the output?

let person = { name: 'Lydia' };
const members = [person];
person = null;

console.log(members);
46. What's the output?

javob variantlari:
Anonymous Quiz
0%
A: null
0%
B: [null]
0%
C: [{}]
100%
D: [{ name: "Lydia" }]
47. What's the output?

const person = {
name: 'Lydia',
age: 21,
};

for (const item in person) {
console.log(item);
}
48. What's the output?

console.log(3 + 4 + '5');
Anonymous Quiz
0%
A: "345"
100%
B: "75"
0%
C: 12
0%
D: "12"
49. What's the value of num?

const num = parseInt('7*6', 10);
Anonymous Quiz
0%
A: 42
0%
B: "42"
100%
C: 7
0%
D: NaN
50. What's the output?

[1, 2, 3].map(num => {
if (typeof num === 'number') return;
return num * 2;
});
51. What's the output?

function getInfo(member, year) {
member.name = 'Lydia';
year = '1998';
}

const person = { name: 'Sarah' };
const birthYear = '1997';

getInfo(person, birthYear);

console.log(person, birthYear);