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

async function getData() {
return await Promise.resolve('I made it!');
}

const data = getData();
console.log(data);
74. What's the output?

function addToList(item, list) {
return list.push(item);
}

const result = addToList('apple', ['banana']);
console.log(result);
74. What's the output?

Javob variantlari;
Anonymous Quiz
0%
A: ['apple', 'banana']
50%
B: 2
0%
C: true
50%
D: undefined
75. What's the output?

const box = { x: 10, y: 20 };

Object.freeze(box);

const shape = box;
shape.x = 100;

console.log(shape);
76. What's the output?

const { firstName: myName } = { firstName: 'Lydia' };

console.log(firstName);
76. What's the output?

Javob variantlari:
Anonymous Quiz
0%
A: "Lydia"
0%
B: "myName"
0%
C: undefined
100%
D: ReferenceError
77. Is this a pure function?

function sum(a, b) {
return a + b;
}
77. Is this a pure function?

Javob variantlari:
Anonymous Quiz
100%
A: Yes
0%
B: No
78. What is the output?

const add = () => {
const cache = {};
return num => {
if (num in cache) {
return `From cache! ${cache[num]}`;
} else {
const result = num + 10;
cache[num] = result;
return `Calculated! ${result}`;
}
};
};

const addFunction = add();
console.log(addFunction(10));
console.log(addFunction(10));
console.log(addFunction(5 * 2));
79. What is the output?

const myLifeSummedUp = ['☕️', '💻', '🍷', '🍫'];

for (let item in myLifeSummedUp) {
console.log(item);
}

for (let item of myLifeSummedUp) {
console.log(item);
}
80. What is the output?

const list = [1 + 2, 1 * 2, 1 / 2];
console.log(list);
81. What is the output?

function sayHi(name) {
return `Hi there, ${name}`;
}

console.log(sayHi());
82. What is the output?

var status = '😎';

setTimeout(() => {
const status = '😍';

const data = {
status: '🥑',
getStatus() {
return this.status;
},
};

console.log(data.getStatus());
console.log(data.getStatus.call(this));
}, 0);