31615
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript 🚀 Don't miss our Quizzes! Let's chat: @nairihar
CHALLENGE
function mysteryFunction() {
console.log(x);
console.log(y);
console.log(z);
var x = 'declared';
let y = 'block-scoped';
const z = 'constant';
console.log(x);
console.log(y);
console.log(z);
}
mysteryFunction();
Читать полностью…
CHALLENGE
const obj = {
value: 42,
[Symbol.toPrimitive](hint) {
if (hint === 'number') return this.value * 2;
if (hint === 'string') return `Value: ${this.value}`;
return this.value + 10;
}
};
console.log(+obj);
console.log(`${obj}`);
console.log(obj + 5);
console.log(Number(obj));
Читать полностью…
✌️ Date is out, Temporal is in
Temporal is the Date system we always wanted in JavaScript. It's extremely close to being available so Mat Marquis thought it would be a good idea to explain exactly what is better about this new JavaScript date system.
Mat “Wilto” Marquis
CHALLENGE
const user = { name: 'Sarah', age: 0 };
const config = { theme: '', debug: false };
const result1 = user.age || 25;
const result2 = user.name && user.name.toUpperCase();
const result3 = config.theme || 'light';
const result4 = config.debug && console.log('Debug mode') || 'disabled';
console.log(result1);
console.log(result2);
console.log(result3);
console.log(result4);
Читать полностью…
CHALLENGE
const pipe = (...fns) => (value) => fns.reduce((acc, fn) => fn(acc), value);Читать полностью…
const add = (x) => (y) => x + y;
const multiply = (x) => (y) => x * y;
const subtract = (x) => (y) => y - x;
const transform = pipe(
add(5),
multiply(3),
subtract(2)
);
console.log(transform(4));
console.log(transform(0));
CHALLENGE
function highlight(strings, ...values) {
return strings.reduce((result, str, i) => {
const value = values[i] ? `<em>${values[i]}</em>` : '';
return result + str + value;
}, '');
}
const name = 'Sarah';
const score = 95;
const message = highlight`Hello ${name}, your score is ${score}!`;
console.log(message);
Читать полностью…
CHALLENGE
const data = [Читать полностью…
{ type: 'income', amount: 1000, category: 'salary' },
{ type: 'expense', amount: 200, category: 'food' },
{ type: 'income', amount: 500, category: 'freelance' },
{ type: 'expense', amount: 150, category: 'transport' }
];
const result = data.reduce((acc, item) => {
const key = item.type;
acc[key] = (acc[key] || 0) + item.amount;
return acc;
}, {});
console.log(result.income - result.expense);
CHALLENGE
console.log(typeof myVar);Читать полностью…
console.log(typeof myFunc);
console.log(typeof myArrow);
var myVar = 'initialized';
function myFunc() {
return 'function declaration';
}
var myArrow = () => 'arrow function';
console.log(typeof myVar);
console.log(typeof myFunc);
console.log(typeof myArrow);
CHALLENGE
const config = { api: 'v1', timeout: 5000 };
Object.seal(config);
const settings = { theme: 'dark', lang: 'en' };
Object.freeze(settings);
config.api = 'v2';
config.retries = 3;
settings.theme = 'light';
settings.debug = true;
console.log(config.api);
console.log(config.retries);
console.log(settings.theme);
console.log(settings.debug);
Читать полностью…
CHALLENGE
const obj = { a: 1, b: 2, c: 3 };
const entries = Object.entries(obj);
const keys = Object.keys(obj);
const values = Object.values(obj);
const result = {
entriesLength: entries.length,
keysJoined: keys.join('-'),
valuesSum: values.reduce((sum, val) => sum + val, 0),
firstEntry: entries[0]
};
console.log(result.entriesLength);
console.log(result.keysJoined);
console.log(result.valuesSum);
console.log(result.firstEntry);
Читать полностью…
CHALLENGE
const user = {
name: 'Sarah',
age: 28,
getName() {
return this.name;
}
};
const { getName } = user;
const boundGetName = user.getName.bind(user);
console.log(getName());
console.log(boundGetName());
console.log(user.getName());
Читать полностью…
CHALLENGE
async function fetchData() {
return Promise.resolve('data');
}
async function processData() {
console.log('start');
const result = fetchData();
console.log(typeof result);
const data = await fetchData();
console.log(typeof data);
console.log('end');
}
processData();
Читать полностью…
Happy New Year! 🎄 🍾
Wishing you fewer meetings, more merges, and no Friday deploys. 😆
@JavaScript Telegram Newsletter Team
🤟 Node.js v25.4.0 is out!
• require(esm) now stable and a new CLI flag: --require-module
• Module compile cache now stable
• http.setGlobalProxyFromEnv() added
• Multiple APIs promoted to stable (heapsnapshot, build snapshot, `v8.queryObjects`)
• Root CAs updated to NSS 3.117
• Several semver-minor improvements across events, module, stream, process, util
Rafael Gonzaga
A year ago, developer Dimitri Mitropoulos got Doom to run inside TypeScript's type system. Now, he's joined Dillon Mulroy (above) 😉 to walk through the entirety of how it works (in a mere six hours!)
Читать полностью…
CHALLENGE
const numbers = [1, 2, 3, 4, 5, 6];Читать полностью…
const result = numbers
.map(x => x * 2)
.filter(x => x > 6)
.reduce((acc, x) => {
console.log(`Processing ${x}, acc: ${acc}`);
return acc + x;
}, 0);
console.log(`Final result: ${result}`);
CHALLENGE
const obj = {
name: 'Calculator',
values: [1, 2, 3, 4, 5],
regular: function() {
return this.values.filter(function(x) {
return x > 2;
}).length;
},
arrow: function() {
return this.values.filter(x => x > 2).length;
},
broken: () => {
return this.values.filter(x => x > 2).length;
}
};
console.log(obj.regular());
console.log(obj.arrow());
try {
console.log(obj.broken());
} catch(e) {
console.log('Error');
}
Читать полностью…
✌️ Web Dependencies are Broken; Can We Fix Them?
Lea, who has worked at the heart of Web Standards for years, delivers a compelling (and educational) call to action about a problem every JavaScript developer has encountered: why is managing dependencies and introducing them into code so unnecessarily messy and what could we do about it?
Lea Verou
CHALLENGE
class Counter {
#value = 0;
get count() {
console.log('Getting count');
return this.#value;
}
set count(val) {
console.log('Setting count to', val);
this.#value = Math.max(0, val);
}
}
const counter = new Counter();
counter.count = -5;
console.log(counter.count);
Читать полностью…
CHALLENGE
async function processData() {
const promise1 = Promise.resolve('first');
const promise2 = Promise.reject('error');
const promise3 = Promise.resolve('third');
try {
const result = await Promise.allSettled([promise1, promise2, promise3]);
console.log(result[0].status);
console.log(result[1].reason);
console.log(result[2].value);
} catch (error) {
console.log('caught:', error);
}
}
processData();
Читать полностью…
👀 For years, Mozilla, Apple, and the CSS Working Group have been working to bring "masonry" layouts (as above) natively to CSS. The concept is now called CSS Grid Lanes and here's how it works. You can already try it out in Safari Technology Preview 234.
Читать полностью…
✌️🌲📸🟠🔵 Schedule-X 3.6: A Material Design Calendar and Date Picker
Available in the form of React/Preact, Vue, Svelte, Angular, or plain JS components. Open source but with a premium version with extra features. GitHub repo.
Tom Österlund
😮 The 2025 JavaScript Rising Stars
At the start of each year, Michael rounds up the projects in the JavaScript ecosystem that gained the most popularity on GitHub in the prior year. After a two-year run of topping the chart, shadcn/ui has been pushed down to #3 by n8n and React Bits. This is a fantastic roundup, now in its tenth(!) year, and features commentary from a few industry experts too.
Michael Rambeau et al.
CHALLENGE
function* outer() {
yield 1;
yield* inner();
yield 4;
}
function* inner() {
yield 2;
yield 3;
}
const gen = outer();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next().value);
Читать полностью…
CHALLENGE
function* fibonacci() {
let a = 0, b = 1;
yield a;
yield b;
while (true) {
let next = a + b;
yield next;
a = b;
b = next;
}
}
const gen = fibonacci();
const results = [];
for (let i = 0; i < 6; i++) {
results.push(gen.next().value);
}
console.log(results.join(','));
Читать полностью…
CHALLENGE
class Vehicle {
#engine = 'V6';
static count = 0;
constructor(type) {
this.type = type;
Vehicle.count++;
}
static getCount() {
return this.count;
}
get info() {
return `${this.type} with ${this.#engine}`;
}
}
class Car extends Vehicle {
static count = 0;
constructor(brand) {
super('car');
this.brand = brand;
Car.count++;
}
}
const tesla = new Car('Tesla');
const ford = new Car('Ford');
console.log(Vehicle.getCount());
console.log(Car.getCount());
console.log(tesla.info);
Читать полностью…
CHALLENGE
function createCounter() {
let count = 0;
return function(increment = 1) {
count += increment;
return count;
};
}
const counter1 = createCounter();
const counter2 = createCounter();
console.log(counter1());
console.log(counter1(5));
console.log(counter2(3));
console.log(counter1());
console.log(counter2());
Читать полностью…