Daily JavaScript
15 subscribers
1 photo
1 link
Daily examples, coding challenges, and useful tips for developers.
Download Telegram
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);
52. What's the output?

function greeting() {
throw 'Hello world!';
}

function sayHi() {
try {
const data = greeting();
console.log('It worked!', data);
} catch (e) {
console.log('Oh no an error:', e);
}
}

sayHi();
53. What's the output?

function Car() {
this.make = 'Lamborghini';
return { make: 'Maserati' };
}

const myCar = new Car();
console.log(myCar.make);
53. What's the output?

Javob variantlari:
Anonymous Quiz
0%
A: "Lamborghini"
100%
B: "Maserati"
0%
C: ReferenceError
0%
D: TypeError
54. What's the output?

(() => {
let x = (y = 10);
})();

console.log(typeof x);
console.log(typeof y);
55. What's the output?

class Dog {
constructor(name) {
this.name = name;
}
}

Dog.prototype.bark = function() {
console.log(`Woof I am ${this.name}`);
};

const pet = new Dog('Mara');

pet.bark();

delete Dog.prototype.bark;

pet.bark();