What is the output?
Anonymous Quiz
25%
function function 15 84
40%
function function 60 84
21%
function number 60 84
14%
function function 60 84
β€5π2π₯2π€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);β€6π2π₯2
What is the output?
Anonymous Quiz
22%
Language: <JAVASCRIPT>, introduced in [2015], feature: <TEMPLATES>!
35%
Language: JAVASCRIPT, introduced in 4030, feature: TEMPLATES!
22%
Language: <javascript>, introduced in [4030], feature: <templates>!
21%
Language: <JAVASCRIPT>, introduced in [4030], feature: <TEMPLATES>!
β€3π₯2π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);β€4π₯3
What is the output?
Anonymous Quiz
19%
20 42 Missing: platinum
41%
10 42 Missing: platinum
23%
20 -84 undefined
17%
20 84 Missing: platinum
β€4π₯2π1
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);π₯2π1
What is the output?
Anonymous Quiz
29%
[ 2, 4, 6, 10, 11 ]
41%
[ 2, 4, 6, 8, 10, 11, 12 ]
18%
[ 2, 4, 6, 10, 11, 12 ]
13%
[ 1, 2, 3, 10, 11 ]
β€2
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
β€4π₯4π€3π€©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β€1
CHALLENGE
const str = " Hello, World! ";
const result = str
.trim()
.split(", ")
.map((word, i) => {
if (i % 2 === 0) return word.toUpperCase();
return word.toLowerCase().replace("!", "@");
})
.reverse()
.join(" | ");
console.log(result);
β€3
What is the output?
Anonymous Quiz
21%
HELLO | world@
27%
HELLO | WORLD!
14%
hello | WORLD@
39%
world@ | HELLO
π₯8β€5π1
Please open Telegram to view this post
VIEW IN TELEGRAM
π5π₯2β€1
CHALLENGE
function Vehicle(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
this.speed = 0;
}
Vehicle.prototype.accelerate = function (amount) {
this.speed += amount;
return this;
};
Vehicle.prototype.describe = function () {
return `${this.year} ${this.make} ${this.model} going ${this.speed}km/h`;
};
function ElectricVehicle(make, model, year, range) {
Vehicle.call(this, make, model, year);
this.range = range;
}
ElectricVehicle.prototype = Object.create(Vehicle.prototype);
ElectricVehicle.prototype.constructor = ElectricVehicle;
ElectricVehicle.prototype.describe = function () {
return Vehicle.prototype.describe.call(this) + ` | Range: ${this.range}km`;
};
const car = new ElectricVehicle("Tesla", "Model 3", 2023, 500);
car.accelerate(60).accelerate(40);
console.log(car.describe());
console.log(car instanceof ElectricVehicle);
console.log(car instanceof Vehicle);
console.log(car.constructor === ElectricVehicle);β€2
What is the output?
Anonymous Quiz
23%
2023 Tesla Model 3 going 100km/h | Range: 500km true true false
29%
2023 Tesla Model 3 going 100km/h | Range: 500km true false true
31%
2023 Tesla Model 3 going 60km/h | Range: 500km true true true
17%
2023 Tesla Model 3 going 100km/h | Range: 500km true true true
β€4π₯1
Google has open sourced a new tool (JSIR) and proposed an industry-standard IR (Intermediate Representation β if an AST tells you what the code looks like, an IR tells you what it does) for JavaScript. Already used at Google for analysis and code transformation, the underlying idea could form a foundation for a new generation of tooling.
Zhixun Tan (Google)
Please open Telegram to view this post
VIEW IN TELEGRAM
β€4π4π₯2
CHALLENGE
function createUser(
name,
role = "viewer",
permissions = [role],
metadata = { createdBy: name, level: permissions.length }
) {
return { name, role, permissions, metadata };
}
const user1 = createUser("Carlos");
const user2 = createUser("Diana", "admin", ["read", "write", "delete"]);
const user3 = createUser("Eve", "editor", undefined, { createdBy: "system", level: 99 });
console.log(user1.role, user1.permissions, user1.metadata.level);
console.log(user2.metadata.createdBy, user2.permissions.length);
console.log(user3.permissions[0], user3.metadata.level);
β€1π1π₯1
What is the output?
Anonymous Quiz
24%
viewer [ 'viewer' ] 1 Carlos 3 editor 99
26%
viewer [ 'role' ] 1 Diana 3 editor 1
40%
viewer [ 'viewer' ] 1 Diana 3 editor 99
10%
viewer [ 'viewer' ] 0 Diana 3 editor 99
β€3π€3π2
In CSS is DOOMed, Niels Leenheer shows off how he implemented a version of 1993's Doom using purely CSS rendering (with the game logic in JavaScript). Play it for yourself or check out the code.
π₯7β€4
CHALLENGE
const name = "Carlos";
const age = 28;
const score = 95;
const player = {
name,
age,
score,
greet() {
return `${this.name} (${this.age}) scored ${this.score}`;
},
get rank() {
return this.score >= 90 ? "Gold" : "Silver";
}
};
const { name: playerName, rank, greet } = player;
console.log(`${playerName} | ${rank} | ${greet.call(player)}`);
π€5β€2π1