TGViewer
Channel Public Channel
JavaScript

JavaScript

@javascript

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
Subscribers
31K
Photos
1.2K
Videos
10
Links
899

Showing posts older than #2274 Β· Back to latest

Older Posts 20 shown
Post #2273 5.08K
  • πŸ‘ 11
  • πŸ€” 6
  • ❀ 4
Post #2272 4.91K
CHALLENGE

const a = 9007199254740991n;
const b = 2n;

function performCalculation() {
const c = a + 1n;
const d = c / b;
const e = d * 2n - 1n;

const result = Number(e) === Number(a);
console.log(result);
}

performCalculation();
  • πŸ‘ 7
Post #2271 5.04K
✌️ You Don't Know JS Yet: The Unbooks

This ~420pg ebook is a collection of all 4 remaining "unbooks" of the 2nd edition of "You Don't Know JS Yet" book series.

Kyle Simpson
  • πŸ‘ 10
  • ❀ 4
  • πŸ”₯ 4
  • πŸ€” 1
Post #2270 4.73K
  • πŸ”₯ 8
  • ❀ 4
  • πŸ‘ 4
Post #2269 4.58K
CHALLENGE

console.log('Start');

setTimeout(() => {
console.log('Timeout 1');
}, 0);

Promise.resolve().then(() => {
console.log('Promise 1');
}).then(() => {
console.log('Promise 2');
});

setTimeout(() => {
console.log('Timeout 2');
}, 0);

console.log('End');
  • ❀ 4
Post #2267 5.25K
  • πŸ”₯ 7
  • ❀ 5
  • πŸ‘ 1
  • πŸ€” 1
Post #2266 5.06K
CHALLENGE

function processConfig(config) {
const defaults = {
timeout: 1000,
retries: 3,
enabled: false,
count: 0
};

const settings = {
...defaults,
...config
};

const effectiveTimeout = settings.timeout ?? 500;
const effectiveRetries = settings.retries ?? 1;
const effectiveEnabled = settings.enabled ?? true;
const effectiveCount = settings.count ?? 5;

console.log([effectiveTimeout, effectiveRetries, effectiveEnabled, effectiveCount]);
}

processConfig({ timeout: null, retries: 0, enabled: undefined });
  • πŸ‘ 5
  • πŸ€” 1
Post #2264 5.24K
  • ❀ 2
  • πŸ€” 2
Post #2263 5.03K
CHALLENGE

const companies = [
{ name: 'TechCorp', founded: 2010 },
{ name: 'DataSystems', founded: 2015 },
{ name: 'WebSolutions', founded: 2008 }
];

const activeClients = new WeakSet();

activeClients.add(companies[0]);
activeClients.add(companies[2]);

companies.pop();

const result = [
activeClients.has(companies[0]),
activeClients.has(companies[1]),
typeof activeClients.size
];

console.log(result);
  • ❀ 4
  • πŸ‘ 1
  • πŸ€” 1
Post #2261 4.52K
  • πŸ€” 10
  • πŸ‘ 9
  • ❀ 1
Post #2260 4.87K
CHALLENGE

const user = {
profile: {
name: 'Alice',
settings: {
notifications: {
email: true,
sms: false
}
}
},
getPreference(type) {
return this.profile?.settings?.notifications?.[type] ?? 'not configured';
}
};

const admin = {
profile: {
name: 'Admin',
settings: null
},
getPreference: user.getPreference
};

console.log(admin.getPreference('email'));
  • πŸ‘ 4
  • ❀ 2
Post #2258 5.19K
  • πŸ‘ 9
  • ❀ 3
  • πŸ”₯ 2
Post #2257 5.1K
CHALLENGE

const team = {
members: ['Alice', 'Bob', 'Charlie'],
[Symbol.iterator]: function*() {
let index = 0;
while(index < this.members.length) {
yield this.members[index++].toUpperCase();
}
}
};

const result = [];
for (const member of team) {
result.push(member);
}

console.log(result.join('-'));
  • πŸ‘ 4
Post #2256 4.9K
πŸ‘ A Flowing WebGL Gradient, Deconstructed

Even if you don’t want to render a neat plasma-style effect on the Web, this is a wonderfully deep exploration of the math and technology behind doing so using simple GLSL code that could be easily understood by any JavaScript developer.

Alex Harri
  • ❀ 3
  • πŸ‘ 2
  • 🀣 2
Post #2255 4.9K
  • πŸ‘ 6
  • πŸ”₯ 3
  • ❀ 2
Post #2254 4.99K
CHALLENGE

function main() {
console.log(1);

setTimeout(() => console.log(2), 0);

Promise.resolve().then(() => {
console.log(3);
setTimeout(() => console.log(4), 0);
}).then(() => console.log(5));

Promise.resolve().then(() => console.log(6));

console.log(7);
}

main();
  • ❀ 5
  • πŸ‘ 2
Older posts β†’
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’