CHALLENGE
function* idGenerator() {
let id = 1;
while (true) {
yield id++;
}
}
const gen = idGenerator();
const weakMap = new WeakMap();
const objs = [{}, {}, {}];
objs.forEach(obj => weakMap.set(obj, gen.next().value));
const result = objs.map(obj => weakMap.get(obj)).filter(id => id % 2 === 0);
console.log(result);
๐5โค4๐ฅ2
๐3๐ฅ1
A simple abstraction for Node.js worker_threads, allowing you to create and share a Map (hash table) between worker threads and the main process.
Please open Telegram to view this post
VIEW IN TELEGRAM
โค6๐4๐ฅ2
CHALLENGE
const weakMap = new WeakMap();
const obj = {};
(function() {
const obj1 = { name: 'inner' };
weakMap.set(obj1, 'inner value');
})();
const result = weakMap.get(obj);
console.log(result);
๐8
๐14โค4๐ค4๐ฅ1
If you missed the Google I/O Angular session, you missed not only the latest updates on Angular but also the Generative Art Gallery demo which I had so much fun building. The demo has all of my favorite technologies, including AI, Angular and WebXR. It also was a very pleasant developer experience. Let me tell you why!
Ayลegรผl Yรถnet
Please open Telegram to view this post
VIEW IN TELEGRAM
โค5๐3๐ฅ2
CHALLENGE
const weakMap = new WeakMap();
const obj = {};
const gen = (function* () {
yield 'value1';
yield 'value2';
})();
weakMap.set(obj, gen.next().value);
console.log(weakMap.get(obj));
console.log(gen.next().value);
๐4
What is the output?
Anonymous Quiz
17%
Error
27%
"valie1", undefined
46%
"value1", "value2"
10%
"value2", "value2"
๐11โค4๐ค4๐ฅ3
I've always wanted to create a video series to share my experiences and work style as a remote software engineer. I finally started this journey and am excited to make more videos like this...
nairi
Please open Telegram to view this post
VIEW IN TELEGRAM
1๐18๐ฅ7โค5๐ค2๐คฉ1
CHALLENGE
const weakMap = new WeakMap();
const gen = (function* () {
yield { key: 'value1' };
yield { key: 'value2' };
})();
const obj1 = gen.next().value;
const obj2 = gen.next().value;
weakMap.set(obj1, 'stored value1');
weakMap.set(obj2, 'stored value2');
const result = [...gen].map(obj => weakMap.get(obj));
console.log(result);
๐7โค5๐ฅ3๐คฉ2
What is the output?
Anonymous Quiz
17%
[undefined, undefined]
17%
[]
58%
["stored value1", "stored value2"]
9%
[null, null]
๐10๐ฅ6๐ค5โค4
We often feature ECMAScript proposals that are in their later stages, but how about a brand new one you could get involved with? This one proposes an interesting additional bit of language syntax (`?=`) that returns a
[error, value]
tuple from an assignment.Arthur Fiorette
Please open Telegram to view this post
VIEW IN TELEGRAM
2๐7๐ค7โค4๐ฅ2
CHALLENGE
const weakMap = new WeakMap();
const array = [{}, {}];
array.forEach(obj => weakMap.set(obj, obj));
const result = array.map(obj => weakMap.get(obj) === obj);
console.log(result);
2๐8
๐11๐ค5โค4๐ฅ1
Please open Telegram to view this post
VIEW IN TELEGRAM
2๐คฃ50๐8โค5๐ฅ1๐ค1
Sponsored by Bryntum ๐ฎโโ๏ธ
World Class Web Components
โ CHALLENGE
World Class Web Components
const weakMap = new WeakMap();
const obj = {};
(function() {
const internalObj = {};
weakMap.set(internalObj, 'hidden');
obj.ref = internalObj;
})();
delete obj.ref;
const result = weakMap.has(obj.ref);
console.log(result);
Please open Telegram to view this post
VIEW IN TELEGRAM
2๐ฅ7๐ค6๐5โค3
๐1
Sponsored by Bryntum ๐ฎโโ๏ธ
World Class Web Components
๐ฅ Google takes its biggest L ever... now a convicted monopolist
Fireship
World Class Web Components
Fireship
Please open Telegram to view this post
VIEW IN TELEGRAM
3๐คฃ6๐ฅ4โค3๐2
Sponsored by Bryntum ๐ฎโโ๏ธ
World Class Web Components
โ CHALLENGE
World Class Web Components
const weakMap = new WeakMap();
const array = [1, 2, 3];
const obj = {};
weakMap.set(obj, array);
const result = weakMap.get(obj).reduce((acc, val) => acc + val);
console.log(result);
Please open Telegram to view this post
VIEW IN TELEGRAM
๐7
2๐10โค8๐ฅ3