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
901

Showing posts older than #1631 ยท Back to latest

Older Posts 20 shown
Post #1630 5.82K
๐Ÿ˜† So true ...
  • ๐Ÿคฃ 47
  • โค 7
  • ๐Ÿ”ฅ 6
Post #1629 5.56K
  • โค 10
  • ๐Ÿ‘ 7
  • ๐Ÿ”ฅ 1
Post #1628 5.61K
CHALLENGE

function createCounter() {
let count = 0;
return {
increment() {
count++;
return count;
},
getCount() {
return count;
}
};
}

const counter = createCounter();

console.log(counter.increment());
console.log(counter.getCount());
console.log(counter.increment());
console.log(counter.getCount());
  • ๐Ÿ‘ 7
  • โค 4
  • ๐Ÿ”ฅ 3
Post #1627 5.64K
๐ŸŠ Rspack 1.0: The Rust-Powered JavaScript Bundler

Far from being โ€˜yet another bundlerโ€™ with its own approach and terminology to learn, Rspack prides itself on being webpack API and ecosystem compatible, while offering many times the performance. The team now considers it production ready and encourages you to try your webpack-based projects on it.

Rspack Contributors
  • โค 3
  • ๐Ÿ‘ 2
  • ๐Ÿ”ฅ 1
Post #1626 5.4K
  • โค 12
  • ๐Ÿ‘ 8
  • ๐Ÿค” 8
  • ๐Ÿ”ฅ 2
Post #1625 5.47K
โ“ CHALLENGE

const numbers = [0,0,0];

let i = 0;
const result = numbers.reduce((acc, _) => {
return ++acc;
}, i);

console.log(i, result);
  • ๐Ÿ‘ 3
Post #1624 5.97K
  • ๐Ÿ”ฅ 9
  • โค 7
  • ๐Ÿ‘ 6
Post #1623 5.81K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

โ“ CHALLENGE

const obj = {
outer: 1,
inner: {
outer: 10,
inner: 20
}
};

let result = 0;

with (obj) {
result += outer;
with (inner) {
result += outer + inner;
}
}

console.log(result);
  • ๐Ÿ‘ 5
  • ๐Ÿค” 3
  • โค 1
Post #1622 5.32K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

โœŒ๏ธ JS Dates are About to Be Fixed

Handling dates and times is famously a painful area for programmers and JavaScript hasnโ€™t done a lot to make it easier. Libraries like Moment.js help a lot, but Iago looks at how the Temporal proposal and its features will begin to help a lot more over time.

Iago Lastra
  • โค 3
  • ๐Ÿ‘ 3
  • ๐Ÿ”ฅ 1
Post #1621 5.67K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

๐ŸŒฒ How to Create an NPM Package in 2024

Sounds simple, but there are a lot of steps involved if you want to follow best practices, introduce useful tools, and get things just right. Matt Pocock walks through the process here, and thereโ€™s a 14-minute screencast too, if youโ€™d prefer to watch along.

Matt Pocock
  • โค 3
  • ๐Ÿ‘ 3
  • ๐Ÿ”ฅ 1
Post #1620 5.67K
  • ๐Ÿ‘ 8
  • ๐Ÿคฉ 4
  • โค 1
  • ๐Ÿ”ฅ 1
Post #1619 6.04K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

โ“ CHALLENGE


const weakMap = new WeakMap();
const arr = [{}, {}, {}];

arr.forEach((obj, index) => weakMap.set(obj, index));

arr.splice(1, 1); // Remove the second element

const result = arr.map(obj => weakMap.get(obj));

console.log(result);
  • ๐Ÿ‘ 5
  • ๐Ÿ”ฅ 2
  • โค 1
Post #1618 6.01K
  • ๐Ÿ”ฅ 7
  • ๐Ÿ‘ 2
Post #1617 5.89K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

โ“ CHALLENGE


const weakMap = new WeakMap();
const arr = [1, 2, 3, 4];
const objs = arr.map(n => ({ n }));

objs.forEach((obj, index) => weakMap.set(obj, arr.slice(0, index + 1)));

const result = objs.map(obj => weakMap.get(obj).reduce((acc, num) => acc + num, 0));

console.log(result);
  • ๐Ÿ‘ 7
  • โค 2
  • ๐Ÿค” 2
Post #1616 5.36K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

โ“ CHALLENGE


const weakMap = new WeakMap();
let obj = { name: 'initial' };

function changeName(obj) {
weakMap.set(obj, obj.name);
obj.name = 'changed';
}

changeName(obj);

console.log(weakMap.get(obj));
Post #1615 5.27K
  • ๐Ÿ‘ 9
  • โค 1
  • ๐Ÿ”ฅ 1
  • ๐Ÿคฃ 1
Post #1613 5.48K
  • ๐Ÿ”ฅ 8
  • ๐Ÿ‘ 3
Post #1612 5.8K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

โ“ CHALLENGE


function* infiniteGenerator() {
let i = 0;
while (true) {
yield i++;
}
}

const weakMap = new WeakMap();
const gen = infiniteGenerator();

weakMap.set(gen, gen.next().value);

const result = weakMap.get(gen) + gen.next().value;

console.log(result);
  • ๐Ÿ‘ 15
  • ๐Ÿ”ฅ 4
  • โค 3
Post #1611 5.46K
Sponsored by Bryntum ๐Ÿ‘ฎโ€โ™€๏ธ
World Class Web Components

๐ŸŒฒ LogTape: Simple Logging Library with Zero Dependencies

Iโ€™m digging this new style of library that promises support across all the main runtimes (Node, Deno, Bun) as well as edge functions and browser devtools.

Hong Minhee
  • ๐Ÿ‘ 4
  • โค 1
  • ๐Ÿ”ฅ 1
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 โ†’