JavaScript
32.1K subscribers
1.04K photos
10 videos
33 files
722 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

let obj1 = { key: 'value1' };
let obj2 = { key: 'value2' };

const map = new Map();
const weakMap = new WeakMap();

map.set(obj1, 'mapValue');
weakMap.set(obj2, 'weakMapValue');

obj1 = null; // Changing reference
obj2 = null; // Changing reference

console.log(map.has(obj1));
console.log(weakMap.has(obj2));
❀7πŸ‘4πŸ”₯4
πŸ€”22πŸ”₯4🀣4πŸ‘3❀2
CHALLENGE

function* genFunc() {
yield Symbol('A');
yield new Function('return this')();
}

const obj = { key: genFunc().next().value };
obj.key = genFunc().next().value;

console.log(obj.key === globalThis);
πŸ€”5❀4πŸ”₯2πŸ‘1
What is the output?
Anonymous Quiz
37%
false
37%
true
14%
Error
12%
undefined
πŸ€”11❀3🀣2πŸ‘1
😯 Motion Canvas: Create Dynamic Canvas-Rendered Animations

There’s two parts. A library where you use generator functions to procedurally define animations, and an editor that provides a real-time preview of said animations which you can see in action here.

Motion Canvas
Please open Telegram to view this post
VIEW IN TELEGRAM
❀3πŸ‘3πŸ”₯3🀣3
CHALLENGE

const secret = 'hidden';
function revealSecret() {
const secret = 'revealed';
const obj = { secret: 'object secret' };
with (obj) {
return () => secret;
}
}

const mySecret = revealSecret()();
console.log(mySecret);
πŸ‘5πŸ€”5❀4πŸ”₯2
πŸ”₯9πŸ€”7🀩3❀2
❓ KaTeX: The Fastest Math Typesetting Library for the Web

All these AI And machine learning papers and blog posts these days are crammed with mathematical notation, so how about a no dependency, TeX-based approach to rendering them? The sandbox demo page shows off how smooth it is.

Emily Eisenberg and Sophie Alpert
Please open Telegram to view this post
VIEW IN TELEGRAM
❀4πŸ‘2πŸ”₯2
CHALLENGE

const secretKey = Symbol('key');
const secretValue = 'secret';

function Store() {
this[secretKey] = secretValue;
}

Store.prototype.get = function(key) {
return this[key];
};

const store = new Store();
const revealed = store.get(secretKey);
console.log(revealed);
πŸ”₯7πŸ‘6❀3
🌲 10 Modern Node.js Runtime Features to Start Using in 2024

If it ever feels like the new feature spotlight shines too much on Bun or Deno, never fear - Node has been taking huge strides forward too. Liran helps us catch up with a lot of the newest Node features.

Liran Tal
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5πŸ‘4πŸ”₯2
CHALLENGE

function* gen() {
yield 1;
yield 2;
yield 3;
}

async function asyncFunc() {
for (let value of gen()) {
await new Promise(res => setTimeout(res, 100));
console.log(value);
}
return 'done';
}

const result = asyncFunc();
console.log(result instanceof Promise);
❀9
πŸ”₯7πŸ‘3🀣2
🌲 Node is Leaking Memory? setTimeout Could Be The Reason

The folks at Sentry were running into problems with how Node handles timeouts created with setTimeout or, more specifically, problems caused by hanging on to the Timeout objects setTimeout returns..

Armin Ronacher
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘6❀2πŸ”₯2
CHALLENGE

const handler = {
get(target, prop, receiver) {
if (prop === 'secret') {
return Reflect.get(...arguments) + ' exposed';
}
return Reflect.get(...arguments);
}
};

const secretObj = { secret: 'hidden', reveal: 'nothing' };
const proxy = new Proxy(secretObj, handler);

console.log(proxy.secret);
πŸ‘4❀2
πŸ”₯8πŸ€”5πŸ‘4❀2
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5πŸ‘4πŸ”₯4
CHALLENGE

function* generator() {
yield 1;
yield 2;
}

const gen = generator();
const sym = Symbol('unique');

gen[sym] = function() {
return this.next().value;
};

console.log(gen[sym](), gen[sym](), gen[sym]());
πŸ‘7❀1
πŸ‘7❀5πŸ”₯3
πŸ˜†
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣103🀩7πŸ‘3❀2πŸ”₯1
CHALLENGE

const func = new Function('a', 'b', 'return a + b');
console.log(func(1, 2));
πŸ‘5❀2