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

Older Posts 20 shown
Post #2132 5.63K
CHALLENGE

async function fetchData() {
const promise = new Promise(resolve => {
setTimeout(() => resolve('first'), 2000);
});

console.log('start');
const result = await promise;
console.log(result);
console.log('end');
}

fetchData();
const x = 'after';
console.log(x);
  • ❀ 4
  • πŸ‘ 2
Post #2131 6.56K
✌️ JavaScript Fatigue Strikes Back

A developer with β€˜a decade away’ from writing JavaScript returns to find that one thing hasn’t changed: β€œChoosing the right JavaScript framework is hard, man.”

Allen Pike
  • πŸ‘ 9
  • 🀩 3
  • πŸ”₯ 2
  • 🀣 1
Post #2130 5.73K
  • πŸ”₯ 8
  • πŸ‘ 3
  • ❀ 2
Post #2129 5.72K
CHALLENGE

const handler = {
get: (target, prop) => {
if (prop in target) {
return target[prop] * 2;
}
return 100;
}
};

const nums = new Proxy({ a: 5, b: 10 }, handler);
console.log(nums.a, nums.b, nums.c);
  • πŸ”₯ 12
Post #2127 5.94K
  • πŸ‘ 15
  • ❀ 3
  • πŸ”₯ 2
  • πŸ€” 2
Post #2126 5.74K
CHALLENGE

const team = {
captain: { name: 'Jack', age: 35 },
players: ['Bob', 'Alice', 'Mike'],
details: { founded: 2020, league: 'Premier' }
};

const {
captain: { name },
players: [, second],
details: { league: division = 'Amateur' }
} = team;

console.log(`${name}-${second}-${division}`);
  • 🀣 12
  • ❀ 5
  • πŸ‘ 5
Post #2124 5.83K
  • πŸ”₯ 17
  • πŸ‘ 12
  • πŸ€” 10
  • ❀ 1
Post #2123 5.65K
CHALLENGE

const config = {
port: 0,
timeout: null,
retries: '',
cache: false,
debug: undefined
};

const port = config.port ?? 3000;
const timeout = config.timeout ?? 5000;
const retries = config.retries ?? 3;
const cache = config.cache ?? true;
const debug = config.debug ?? false;

console.log([port, timeout, retries, cache, debug]);
  • πŸ‘ 10
Post #2122 5.82K
πŸ₯Ά Announcing TypeScript 5.8

Four months in the making, TypeScript 5.8 lands with a strong Node focus. You can now use require() for ES modules in the nodenext module, there’s a new node18 module for developers who want to keep targeting Node 18, and most notably there’s now an --erasableSyntaxOnly option to ensure no TypeScript-only runtime semantics can be used (ideal if you’re using Node’s type stripping features to run TypeScript code directly).

Microsoft
  • πŸ‘ 8
  • ❀ 4
  • πŸ”₯ 1
Post #2121 5.25K
  • πŸ€” 8
  • πŸ”₯ 5
  • ❀ 1
  • πŸ‘ 1
Post #2120 5.62K
CHALLENGE

async function demo() {
console.log('1');

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

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

await Promise.resolve();
console.log('5');

queueMicrotask(() => console.log('6'));
}

demo();
console.log('7');
  • πŸ‘ 12
  • πŸ”₯ 3
  • ❀ 1
Post #2119 5.7K
  • ❀ 12
  • πŸ”₯ 5
  • πŸ€” 4
  • 🀣 2
  • πŸ‘ 1
Post #2118 5.76K
CHALLENGE

function* range(start, end) {
let current = start;
while (current <= end) {
if (current % 3 === 0) {
current++;
continue;
}
yield current++;
}
}

const gen = range(4, 10);
const result = [...gen];
console.log(result);
  • πŸ‘ 5
Post #2117 6.59K
😱 Multiple Window 3D Scene using Three.js

A quick example of how one can "synchronize" a 3d scene across multiple windows using three.js and localStorage

bgstaal
  • ❀ 19
  • πŸ”₯ 14
  • 🀩 5
  • 🀣 2
  • πŸ€” 1
Post #2116 5.84K
  • πŸ”₯ 11
  • πŸ€” 10
  • πŸ‘ 4
  • ❀ 2
  • 🀣 2
Post #2115 5.71K
CHALLENGE

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

items.add(obj1);
items.add(obj2);

obj2.value = 'test';
console.log(items.has(obj2));

obj2 = null;
setTimeout(() => {
console.log(items.has(obj2));
}, 0);
  • πŸ‘ 9
Post #2114 6K
Thank You for 30k! 🫑

We’ve just hit a major milestone: 30,000 subscribers! ⚑️

Thank you for being part of our community. Your support and engagement mean the world to us, and we’re excited to keep bringing you the content you love.

Stay tuned for more updates and great things ahead!

P.S. Play the video with the sound on.

@JavaScript Newsletter Team

✌️ Check out our emoji pack here

🀝 Collaboration
  • πŸ‘ 20
  • ❀ 9
  • 🀩 5
  • πŸ”₯ 2
Post #2113 5.59K
  • πŸ‘ 17
  • ❀ 7
  • πŸ€” 6
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 β†’