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
π€11β€3π€£2π1
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
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
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
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
What is the output?
Anonymous Quiz
23%
undefined, undefined, undefined
27%
1, 2, 3
15%
1, 1, 1
35%
1, 2, undefined
π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