β€3π2π₯2
Over six months in the making, TypeScript 6.0 is designed to bridge the gap between its self-hosted compiler and the (almost ready) Go-powered native compiler of TypeScript 7.0 .
There are new features (Temporal improvements, RegExp.escape, and more), but most important are the changes to help you prepare for 7.0:
β’ Numerous default changes: strict is now true, module is esnext, rootDir defaults to ., and more.
β’ A change that will affect many apps is types defaulting to [] rather than pulling in everything from node_modules/@types.
β’ Numerous deprecations: the es5 target, emitting AMD, UMD, and SystemJS modules, --baseUrl, and others.
β’ --stableTypeOrdering makes 6.0's type ordering behavior match 7.0's to help diagnose inference differences as you update.
Daniel Rosenwasser (Microsoft)
Please open Telegram to view this post
VIEW IN TELEGRAM
β€11π3π₯1
CHALLENGE
const obj = {
name: "Orion",
greet() {
const inner = () => {
console.log(this.name);
};
inner();
},
greetRegular: function () {
const inner = function () {
console.log(this?.name ?? "undefined");
};
inner();
},
};
obj.greet();
obj.greetRegular();
β€2π₯2π1
What is the output?
Anonymous Quiz
31%
Orion Orion
47%
Orion undefined
14%
undefined Orion
8%
undefined undefined
π4β€2
Three reasons your node_modules is huge: needless ES3-era compat packages, micro-libraries with a single consumer, and ponyfills for APIs that shipped years ago! James, known for the e18e ecosystem performance project, offers some ways to calm the chaos.
James Garbutt
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π₯3
CHALLENGE
const operations = {
add: (a, b) => a + b,
subtract: (a, b) => a - b,
multiply: (a, b) => a * b,
divide: (a, b) => b !== 0 ? a / b : null,
};
const pipeline = (...fns) => (value) => fns.reduce((acc, fn) => fn(acc), value);
const double = (x) => operations.multiply(x, 2);
const addTen = (x) => operations.add(x, 10);
const halve = (x) => operations.divide(x, 2);
const subtractThree = (x) => operations.subtract(x, 3);
const transform = pipeline(double, addTen, halve, subtractThree);
console.log(transform(5));
β€6
β€2π₯2
CHALLENGE
"use strict";
function createCounter() {
let count = 0;
return {
increment() { count++; },
getCount() { return count; },
reset: function() { count = 0; }
};
}
const counter = createCounter();
counter.increment();
counter.increment();
counter.increment();
const { getCount, reset } = counter;
try {
reset();
console.log("After reset:", counter.getCount());
} catch (e) {
console.log("Error:", e.message);
}
console.log("Direct call:", counter.getCount());
β€4π₯1
What is the output?
Anonymous Quiz
24%
Error: Cannot set properties of undefined
22%
Error: count is not defined
27%
After reset: 3 Direct call: 3
27%
After reset: 0 Direct call: 0
β€4π₯2π1
CHALLENGE
const obj = {
name: "Quantum",
regular: function () {
return this.name;
},
arrow: () => {
return this?.name;
},
nested: function () {
const inner = () => this.name;
return inner();
},
};
console.log(obj.regular());
console.log(obj.arrow());
console.log(obj.nested());
β€2π2
What is the output?
Anonymous Quiz
29%
Quantum Quantum Quantum
18%
undefined undefined Quantum
36%
Quantum undefined Quantum
18%
Quantum undefined undefined
β€5π3π₯1π€1
CHALLENGE
const curry = (fn) => {
const arity = fn.length;
return function curried(...args) {
if (args.length >= arity) {
return fn(...args);
}
return (...moreArgs) => curried(...args, ...moreArgs);
};
};
const volume = (l, w, h) => l * w * h;
const curriedVolume = curry(volume);
const withLength5 = curriedVolume(5);
const withLength5Width3 = withLength5(3);
console.log(typeof withLength5);
console.log(typeof withLength5Width3);
console.log(withLength5Width3(4));
console.log(curriedVolume(2)(6)(7));β€5π2π₯2
What is the output?
Anonymous Quiz
25%
function function 15 84
44%
function function 60 84
21%
function number 60 84
10%
function function 60 84
β€5π2π₯1π€1π€£1
CHALLENGE
function highlight(strings, ...values) {
return strings.reduce((result, str, i) => {
const value = values[i - 1];
const formatted =
typeof value === "number"
? `[${value * 2}]`
: `<${String(value).toUpperCase()}>`;
return result + formatted + str;
});
}
const language = "javascript";
const year = 2015;
const feature = "templates";
const output = highlight`Language: ${language}, introduced in ${year}, feature: ${feature}!`;
console.log(output);β€4π2
What is the output?
Anonymous Quiz
21%
Language: <JAVASCRIPT>, introduced in [2015], feature: <TEMPLATES>!
36%
Language: JAVASCRIPT, introduced in 4030, feature: TEMPLATES!
21%
Language: <javascript>, introduced in [4030], feature: <templates>!
21%
Language: <JAVASCRIPT>, introduced in [4030], feature: <TEMPLATES>!
β€3π1π₯1
CHALLENGE
const handler = {
get(target, prop, receiver) {
if (prop in target) {
return Reflect.get(target, prop, receiver) * 2;
}
return `Missing: ${prop}`;
},
set(target, prop, value) {
if (typeof value !== "number") {
throw new TypeError("Only numbers allowed");
}
return Reflect.set(target, prop, Math.abs(value));
},
};
const store = new Proxy({ gold: 10, silver: 5 }, handler);
store.bronze = -42;
console.log(store.gold);
console.log(store.bronze);
console.log(store.platinum);β€3π₯1
What is the output?
Anonymous Quiz
18%
20 42 Missing: platinum
46%
10 42 Missing: platinum
20%
20 -84 undefined
16%
20 84 Missing: platinum
β€4π₯2
CHALLENGE
function* range(start, end) {
while (start < end) {
yield start++;
}
}
function* evens(iter) {
for (const val of iter) {
if (val % 2 === 0) yield val;
}
}
function* take(n, iter) {
let count = 0;
for (const val of iter) {
if (count++ >= n) return;
yield val;
}
}
function* pipeline() {
yield* take(3, evens(range(1, 20)));
yield* take(2, range(10, 15));
}
const result = [...pipeline()];
console.log(result);What is the output?
Anonymous Quiz
35%
[ 2, 4, 6, 10, 11 ]
42%
[ 2, 4, 6, 8, 10, 11, 12 ]
14%
[ 2, 4, 6, 10, 11, 12 ]
10%
[ 1, 2, 3, 10, 11 ]
β€1
Axios is an HTTP library that gets 100M+ downloads a week, largely due to its legacy popularity. An attacker took advantage of that to roll out a version with a malicious dependency including a remote access trojan (though Axios' codebase itself was fine). This is big, as even if you donβt use Axios, your dependencies might. Here's how to see if you're affected.
Ashish Kurmi
Please open Telegram to view this post
VIEW IN TELEGRAM
β€3π€3π₯2π€©1
CHALLENGE
const delay = (ms, val) => new Promise(res => setTimeout(res, ms, val));
const p1 = delay(300, "alpha");
const p2 = Promise.reject("network error");
const p3 = delay(100, "gamma");
const p4 = Promise.reject("timeout");
Promise.allSettled([p1, p2, p3, p4]).then(results => {
const summary = results.map(r =>
r.status === "fulfilled"
? `ok:${r.value}`
: `fail:${r.reason}`
);
console.log(summary.join(" | "));
});
π3π₯2