π€16π14π€£11β€2π₯2
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£75π€13π€©2
CHALLENGE
const WM = new WeakMap();
let obj = {};
let anotherObj = {};
WM.set(obj, 'object data');
WM.set(anotherObj, 'another object data');
obj = null;
// Let's check what's logged
console.log(WM.has(obj));
console.log(WM.has(anotherObj));
π9β€1
β€7π6π₯4
CHALLENGE
const mySet = new Set();
mySet.add(10);
mySet.add(20);
mySet.add(10);
mySet.add(30);
console.log(mySet.size);
π13
π€29π€£22π15β€10π€©1
CHALLENGE
function* customGenerator() {
yield 'Hello';
yield 'World';
return 'Done';
}
const gen = customGenerator();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);
π7β€1
What is the output?
Anonymous Quiz
21%
Hello, World, undefined
61%
Hello, World, Done
13%
Hello, World, undefined
5%
Hello, undefined, undefined
π14π€£14β€8
CHALLENGE
const myObject = {
a: 1,
b: 2,
c: 3,
[Symbol.iterator]: function* () {
for (let key of Object.keys(this)) {
yield this[key];
}
}
};
const iter = myObject[Symbol.iterator]();
console.log(iter.next().value);
console.log(iter.next().value);
console.log(iter.next().value);
β€3π3π€©1
What is the output?
Anonymous Quiz
65%
1 2 3
13%
1 1 1
11%
2 3 undefined
10%
undefined undefined undefined
β€12π€£10
Itβs time to fully wave goodbye to 2024, but not before Michael Rambeauβs annual analysis of which JavaScript projects fared best on GitHub over the past year. Even if you dislike GitHub stars as a metric for anything, this remains a great way to get a feel for the JavaScript ecosystem and see what libraries and tools have mindshare in a variety of niches. A fantastic roundup as always.
Michael Rambeau
Please open Telegram to view this post
VIEW IN TELEGRAM
π10β€2π₯2
CHALLENGE
var obj = { a: 10, b: 20 };
with (obj) {
var result = a + b;
}
console.log(result);
π4β€1
π€£23π7π€7β€4π₯2
An email parsing library happy in most JS runtimes. Takes the raw source of emails and parses them into their constituent parts.
Postal Systems
Please open Telegram to view this post
VIEW IN TELEGRAM
π7β€2π₯1
CHALLENGE
function trickyFunction() {
let a = 5;
let b = '5';
let c = 5;
if (a == b && b === c) {
console.log('Condition 1');
} else if (a === c || b == c) {
console.log('Condition 2');
} else {
console.log('Condition 3');
}
}
trickyFunction();
π6π₯2
π27π€£15β€4π€4π₯1
π Play Tetris in a PDF File
I'll let you decide if this one is fun or frightening! Whether or not this will work depends on your PDF reader or browser support, but it works with Chrome and Firefox, at least.
The PDF document format supports embedded JavaScript and this experiment uses it to implement a game of Tetris. The developer, Thomas Rinsma, has used Python to output the PostScript that includes the game's JavaScript. Couple that with the fact many browser PDF renderers are themselves implemented in JavaScript (e.g. PDF.js) and you have a veritable Matryoshka doll of technologies at play here.
I'll let you decide if this one is fun or frightening! Whether or not this will work depends on your PDF reader or browser support, but it works with Chrome and Firefox, at least.
The PDF document format supports embedded JavaScript and this experiment uses it to implement a game of Tetris. The developer, Thomas Rinsma, has used Python to output the PostScript that includes the game's JavaScript. Couple that with the fact many browser PDF renderers are themselves implemented in JavaScript (e.g. PDF.js) and you have a veritable Matryoshka doll of technologies at play here.
π€£10π6β€2π€2
CHALLENGE
function displayArguments() {
console.log(arguments.length);
console.log(arguments[0]);
console.log(arguments[2]);
}
displayArguments('Hello', 'World', 'JavaScript', 'Quiz');
π€8π€£7β€3π3π₯2
What is the output?
Anonymous Quiz
12%
3 Hello undefined
7%
4 World Quiz
77%
4 Hello JavaScript
4%
4 Hello Quiz
π€£23π20β€6
The polished demos show a lot of effort has been put in here. GitHub repo.
Yair Even-Or
Please open Telegram to view this post
VIEW IN TELEGRAM
β€4π3π₯2π€1