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 #2173 Β· Back to latest

Older Posts 20 shown
Post #2171 5.76K
  • πŸ‘ 13
  • πŸ€” 3
  • πŸ”₯ 2
  • ❀ 1
Post #2170 5.37K
CHALLENGE

let x = 1;
function outer() {
let x = 2;
function inner() {
console.log(x);
let x = 3;
}
inner();
}
outer();
  • πŸ‘ 8
Post #2169 5.66K
🀟 Node.js Gets an Official Community Space on Discord

While there have been numerous IRC channels and Discord and Slack servers where Node developers can congregate, the Nodeiflux Discord server has been promoted to being an official one – here’s the invite link if you’re a Discord user. There are already 15k members, so it’s hopping.

Vitullo and Wunder
  • 🀣 8
  • πŸ‘ 6
  • ❀ 1
  • πŸ”₯ 1
Post #2168 5.4K
  • πŸ‘ 10
  • ❀ 1
  • πŸ”₯ 1
Post #2167 5.41K
CHALLENGE

const counter = {
count: 0,
increment() {
this.count++;
return this.count;
}
};

const inc = counter.increment;
const boundInc = counter.increment.bind(counter);

console.log([
counter.increment(),
inc(),
boundInc(),
counter.count
]);
  • πŸ‘ 8
  • ❀ 1
Post #2165 5.08K
  • πŸ‘ 11
  • 🀣 5
  • ❀ 2
  • πŸ”₯ 1
Post #2164 5.1K
CHALLENGE

const cache = new WeakMap();
const obj1 = { id: 1 };
const obj2 = { id: 2 };

cache.set(obj1, 'data1');
cache.set(obj2, 'data2');

obj2.newProp = 'test';

console.log(cache.has(obj1), cache.has(obj2), cache.has({ id: 1 }));
  • πŸ‘ 3
Post #2163 5.9K
  • 🀣 9
  • πŸ€” 5
  • ❀ 2
Post #2162 5.65K
CHALLENGE

async function getData() {
return Promise.resolve(1);
}

async function process() {
try {
const x = await getData();
const y = await Promise.resolve(x + 1);
console.log(y + await Promise.resolve(1));
} catch(err) {
console.log('Error');
}
}

process();
  • πŸ‘ 5
  • ❀ 3
  • πŸ”₯ 1
  • πŸ€” 1
  • 🀣 1
Post #2161 5.9K
πŸ˜†
  • 🀣 110
  • πŸ‘ 9
  • ❀ 3
Post #2160 5.89K
  • πŸ‘ 16
  • 🀣 12
  • πŸ”₯ 5
  • ❀ 3
  • πŸ€” 2
Post #2159 5.45K
CHALLENGE

const users = [
{ id: 1, name: 'Alice', age: 25 },
{ id: 2, name: 'Bob', age: 30 },
{ id: 3, name: 'Charlie', age: 35 }
];

const result = users
.filter(user => user.age > 25)
.map(user => user.name.toUpperCase())
.reduce((acc, name) => acc + name[0], '');

console.log(result);
  • πŸ‘ 4
  • πŸ”₯ 3
  • ❀ 2
Post #2158 6.02K
🀨 A Perplexing JavaScript Parsing Puzzle

It looks deceptively simple – just 14 characters of JavaScript – but after working with JavaScript for 29 years, I got it wrong. A clue: it goes back to a browser-related quirk from 30 years ago..

Hillel Wayne
  • πŸ‘ 3
  • ❀ 2
  • πŸ”₯ 1
Post #2157 5.76K
  • πŸ‘ 8
  • ❀ 4
  • πŸ”₯ 2
Post #2156 5.62K
CHALLENGE

class Task {
constructor(name) {
this.name = name;
}
async execute() {
const result = await Promise.resolve(this.name);
return { result };
}
}

const task = new Task('test');
task.execute().then(console.log);
  • πŸ”₯ 7
  • πŸ‘ 2
  • ❀ 1
Post #2155 5.8K
⭐ A fantastic introduction to latency in IO devices (above) over on the PlanetScale blog, complete with very useful interactive diagrams built in JavaScript.
  • ❀ 4
  • πŸ‘ 2
  • πŸ”₯ 2
Post #2154 5.77K
  • πŸ‘ 8
  • πŸ”₯ 3
  • πŸ€” 3
  • ❀ 2
  • 🀣 1
Post #2153 5.33K
CHALLENGE

const ws = new WeakSet();
const obj1 = { id: 1 };
const obj2 = { id: 2 };

ws.add(obj1);
ws.add(obj2);
ws.delete(obj1);

const obj3 = { id: 2 };

console.log([
ws.has(obj2),
ws.has(obj1),
ws.has(obj3),
ws.has({ id: 2 })
]);
  • πŸ‘ 8
  • πŸ”₯ 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 β†’