JavaScript
31.9K subscribers
1.01K photos
9 videos
33 files
693 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
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
What is the output?
Anonymous Quiz
49%
3
24%
[object Promise]
18%
2
8%
undefined
🀣9πŸ€”5❀2
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
πŸ‘11🀣5❀2πŸ”₯1
Please open Telegram to view this post
VIEW IN TELEGRAM
❀13πŸ”₯4πŸ‘2
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
πŸ‘10❀1πŸ”₯1
🀟 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
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣7πŸ‘5❀1πŸ”₯1
CHALLENGE

let x = 1;
function outer() {
let x = 2;
function inner() {
console.log(x);
let x = 3;
}
inner();
}
outer();
πŸ‘7
πŸ‘13πŸ€”3πŸ”₯2❀1
πŸ” Protect.js: 'Encryption in Use' for Data in Node Apps

Designed to work with any Node framework or ORM, Protect.js provides AES-256 based β€˜encryption in use’ functionality. GitHub repo.

CipherStash
Please open Telegram to view this post
VIEW IN TELEGRAM
❀7πŸ‘2🀣2πŸ”₯1
CHALLENGE

function createCounter() {
let count = 0;

return function() {
count++;
return count;
};
}

const counter1 = createCounter();
const counter2 = createCounter();

counter1();
counter1();
counter2();

const result = counter1() + counter2();
console.log(result);
πŸ‘6🀣6πŸ€”3❀2πŸ”₯1
What is the output?
Anonymous Quiz
13%
6
45%
3
18%
4
23%
5
πŸ€”14🀣11πŸ‘10πŸ”₯6❀4
CHALLENGE

function* fibonacci() {
let [prev, curr] = [0, 1];
while (true) {
yield curr;
[prev, curr] = [curr, prev + curr];
}
}

function* take(iterable, limit) {
for (const item of iterable) {
if (limit <= 0) return;
yield item;
limit--;
}
}

const fibs = [...take(fibonacci(), 5)];
fibs.push(fibs[0] + fibs[1]);
console.log(fibs);
❀3πŸ‘3πŸ€”1
🀨 Rsdoctor 1.0: An Analyzer for Rspack and Webpack

A one-stop, intelligent build analyzer making it easier to identify bottlenecks and optimize performance. It’s part of the same family of tools as Rspack (a Rust-powered web bundler) but is fully webpack compatible. If you’ve ever asked why your build times are too long, this is for you.

ByteDance Inc.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘5πŸ”₯2❀1
❀8πŸ‘1πŸ”₯1
CHALLENGE

function* counter() {
let count = 1;
while (true) {
const reset = yield count++;
if (reset) {
count = 1;
}
}
}

const gen = counter();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next(true).value);
console.log(gen.next().value);
πŸ‘8πŸ”₯2πŸ€”1
πŸ‘9🀣8🀩5πŸ”₯4❀3
πŸ€” How to Build a Snake AI Game with Docker and TensorFlow.js

You’ve probably heard about people β€˜vibe coding’ games by letting LLMs do the coding work, but what if you want to build a game yourself that has neural network powered elements? TensorFlow.js offers one solution that you could just as easily adapt to non-gaming contexts.

Manvar and Raina (Docker)
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘10❀2πŸ”₯2
CHALLENGE

const user = {
profile: {
name: 'Alice',
social: null,
getDetails() {
return { verified: true };
}
}
};

const result = [
user?.profile?.name,
user?.profile?.social?.handle,
user.profile.getDetails?.()?.verified,
user?.nonExistent?.property
];

console.log(result);
πŸ‘7