CHALLENGE
function trickyFunction(a) {
a = a || 42;
let result = (function(a) {
return a * 2;
})(a);
return result;
}
console.log(trickyFunction(0));
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
let x = 1;
function outer() {
let x = 2;
function inner() {
console.log(x);
let x = 3;
}
inner();
}
outer();
What is the output?
Anonymous Quiz
48%
2
34%
ReferenceError: Cannot access 'x' before initialization
8%
1
10%
undefined
A curious quirk of TypeScript’s type system is that it is Turing-complete which has led some developers to implement apps entirely in the type system. One such developer has spent eighteen months producing 177 terabytes of types to get 1993’s Doom running with them. Ridiculous and amazing in equal measure, he
Sarah Gooding (Socket)
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
const user = {
name: 'John',
greet() {
const getName = () => {
console.log(this.name);
};
getName();
},
farewell: function() {
function getName() {
console.log(this.name);
}
getName();
}
};
user.greet();
user.farewell();
What is the output?
Anonymous Quiz
34%
John undefined
39%
John John
13%
undefined undefined
14%
undefined John
A mature Svelte component library for creating interactive node-based UIs and diagrams. v11 adds the ability to toggle between ‘snap grid’ and freeform modes for manipulating elements. (There’s a live demo at the bottom of the homepage.)
Open Source Labs
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
const arr = [1, 2, 3, 4, 5];
const result = arr
.map(x => x * 2)
.filter(x => x > 5)
.reduce((acc, val) => {
return acc + (val % 3 === 0 ? val : 0);
}, 0);
console.log(result);
This media is not supported in your browser
VIEW IN TELEGRAM
Thank You for 30k! 🫡
We’ve just hit a major milestone: 30,000 subscribers!⚡️
Thank you for being part of our community. Your support and engagement mean the world to us, and we’re excited to keep bringing you the content you love.
Stay tuned for more updates and great things ahead!
P.S. Play the video with the sound on.
@JavaScript Newsletter Team
✌️ Check out our emoji pack here
🤝 Collaboration
We’ve just hit a major milestone: 30,000 subscribers!
Thank you for being part of our community. Your support and engagement mean the world to us, and we’re excited to keep bringing you the content you love.
Stay tuned for more updates and great things ahead!
P.S. Play the video with the sound on.
@JavaScript Newsletter Team
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
const items = new WeakSet();
const obj1 = { id: 1 };
const obj2 = { id: 2 };
items.add(obj1);
items.add(obj2);
obj2.value = 'test';
console.log(items.has(obj2));
obj2 = null;
setTimeout(() => {
console.log(items.has(obj2));
}, 0);
What is the output?
Anonymous Quiz
21%
TypeError, TypeError
34%
true, undefined
38%
true, false
8%
true, TypeError
Media is too big
VIEW IN TELEGRAM
A quick example of how one can "synchronize" a 3d scene across multiple windows using three.js and localStorage
bgstaal
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
function* range(start, end) {
let current = start;
while (current <= end) {
if (current % 3 === 0) {
current++;
continue;
}
yield current++;
}
}
const gen = range(4, 10);
const result = [...gen];
console.log(result);
What is the output?
Anonymous Quiz
31%
[4, 5, 6, 7, 8, 9, 10]
16%
[4, 5, 6, 7, 8, 10]
9%
[4, 5, 7, 8, 9, 10]
43%
[4, 5, 7, 8, 10]
CHALLENGE
async function demo() {
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => {
console.log('3');
setTimeout(() => console.log('4'), 0);
});
await Promise.resolve();
console.log('5');
queueMicrotask(() => console.log('6'));
}
demo();
console.log('7');
What is the output?
Anonymous Quiz
25%
1, 7, 5, 3, 6, 2, 4
39%
1, 7, 3, 5, 6, 2, 4
24%
1, 3, 5, 6, 7, 2, 4
12%
1, 7, 3, 5, 2, 6, 4
Four months in the making, TypeScript 5.8 lands with a strong Node focus. You can now use require() for ES modules in the nodenext module, there’s a new node18 module for developers who want to keep targeting Node 18, and most notably there’s now an --erasableSyntaxOnly option to ensure no TypeScript-only runtime semantics can be used (ideal if you’re using Node’s type stripping features to run TypeScript code directly).
Microsoft
Please open Telegram to view this post
VIEW IN TELEGRAM