JavaScript
31.1K subscribers
1.22K photos
10 videos
33 files
894 links
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript 🚀 Don't miss our Quizzes!

Let's chat: @nairihar
Download Telegram
What is the output?
Anonymous Quiz
19%
1 false
44%
1 true
25%
0 true
12%
NaN true
🔥5
CHALLENGE

const a = [] + [];
const b = [] + {};
const c = {} + [];
const d = 1 + "1" - 1;
console.log(a, b, c, d);
🔥2🤔2🤩1
CHALLENGE

let count = 0;
const inc = () => (count += 1, count);
const a = 0 || inc();
const b = null ?? inc();
const c = a && inc();
const d = b?.toString() || inc();
console.log(a, b, c, d, count);
3👍2
👍4🔥3
CHALLENGE

const nums = [1, 2, 3, 4, 5];
const result = nums
.filter(n => n % 2 !== 0)
.map(n => n ** 2)
.reduce((acc, n) => acc + n, 0);

const arr = [10, , 20, undefined, 30];
const mapped = arr.map(x => x * 2);

console.log(result, mapped);
2🔥2
CHALLENGE

let i = 0;
const key = () => `k${i++}`;
const obj = {
[key()]: i,
[key()]: i,
[key()]: i,
};
console.log(Object.keys(obj).join(','), obj.k0, obj.k1, obj.k2);
3
6
CHALLENGE

const a = 5 & 3;
const b = 5 | 2;
const c = ~5;
const d = 1 << 31;
const e = -1 >>> 28;
const f = 5 ^ 5;
console.log(a, b, c, d, e, f);
CHALLENGE

'use strict';

function getValue() {
return this.value;
}

const obj = { value: 42, getValue };
const fn = obj.getValue;

try {
fn();
} catch (err) {
console.log(err.constructor.name, typeof this);
}
2
CHALLENGE

console.log(
typeof typeof 1,
1 + typeof 1,
2 ** 3 ** 2,
1 + 2 + '3',
1 < 2 < 3,
3 > 2 > 1
);