JavaScript


Kanal geosi va tili: Butun dunyo, Inglizcha


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

Bog‘liq kanallar  |  O‘xshash kanallar

Kanal geosi va tili
Butun dunyo, Inglizcha
Statistika
Postlar filtri


What is the output?
So‘rovnoma
  •   -1 1 512 64 0.3
  •   -1 1 512 64 0.30000000000000004
  •   -1 1 64 512 0.30000000000000004
  •   1 -1 512 64 0.30000000000000004
18 ta ovoz


CHALLENGE

const a = -7 % 3;
const b = 7 % -3;
const c = 2 ** 3 ** 2;
const d = (2 ** 3) ** 2;
const e = 0.1 + 0.2;
console.log(a, b, c, d, e);


What is the output?
So‘rovnoma
  •   Sum:\n| End::5,10
  •   Sum:\n End::15
  •   Sum:\n| End::15
  •   Sum: End::15
17 ta ovoz


CHALLENGE

function tag(strings, ...values) {
return strings.raw.join('|') + '::' + values.join(',');
}

const a = 5, b = 10;
console.log(tag`Sum:\n${a + b} End`);


What is the output?
So‘rovnoma
  •   false 1 3 false Symbol(id)
  •   true 1 3 true Symbol(id)
  •   false 1 3 true Symbol(id)
  •   false 3 3 true Symbol(id)
22 ta ovoz


CHALLENGE

const sym1 = Symbol('id');
const sym2 = Symbol('id');

const obj = {
[sym1]: 'first',
[sym2]: 'second',
regular: 'value'
};

const s = Symbol.for('shared');
const s2 = Symbol.for('shared');

console.log(
sym1 === sym2,
Object.keys(obj).length,
Reflect.ownKeys(obj).length,
s === s2,
sym1.toString()
);


What is the output?
So‘rovnoma
  •   1 11 30 true
  •   1 11 31 true
  •   undefined 11 30 true
  •   1 10 30 true
14 ta ovoz


CHALLENGE

async function* gen() {
const x = yield 1;
const y = yield x + 1;
return x + y;
}

async function main() {
const it = gen();
const a = await it.next();
const b = await it.next(10);
const c = await it.next(20);
console.log(`${a.value} ${b.value} ${c.value} ${c.done}`);
}

main();


🎵 Tonny Espeset has recreated the '80s hit Take on Me by A-ha in pure JavaScript (along with synthesized vocals!), running through the always-entertaining Dittytoy online JavaScript music playground.


What is the output?
So‘rovnoma
  •   base-block,base-field,derived-block,derived-field
  •   base-field,base-block,derived-field,derived-block
  •   base-block,derived-block,base-field,derived-field
  •   derived-block,derived-field,base-block,base-field
17 ta ovoz


CHALLENGE

class Base {
static log = [];
static {
Base.log.push('base-block');
}
static value = (() => { Base.log.push('base-field'); return 1; })();
}

class Derived extends Base {
static {
Derived.log.push('derived-block');
}
static value2 = (() => { Derived.log.push('derived-field'); return 2; })();
}

console.log(Derived.log.join(','));


👀 Size Limit: A JavaScript Performance Budgeting Tool

Set a size or load-time budget for your code and this tool can fail CI (or flag a PR) if a change goes over it. You can also do one-off checks and see visualizations of where the bytes are. Framework-agnostic and doesn’t care which bundler or CI you use.

Andrey Sitnik


What is the output?
So‘rovnoma
  •   49 25
  •   19 64
  •   64 19
  •   81 9
15 ta ovoz


CHALLENGE

const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const pipe = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));

const add1 = x => x + 1;
const double = x => x * 2;
const square = x => x * x;

const composed = compose(square, double, add1);
const piped = pipe(square, double, add1);

console.log(composed(3), piped(3));


🤩 The Grand Unifying Architecture of Frontend

SolidJS's creator argues that HTMX, React, LiveView, and friends differ mostly in how they split the same three jobs (navigation, content, and instant UI feedback) between client and server. He then shows how Solid 2.0 aims to cover the whole spectrum.

Ryan Carniato


😮 How Anthropic Made Claude's Apps 3x Faster in Two Weeks

A grab bag of performance lessons from a sprint that cut p75 'time-to-typeable' from 3.1s to 0.55s. Em dashes (the irony!) pushed V8 onto a slower regex path, a stray location.reload() caused half a million hidden reloads a day, and more.

Wang, Attard, and G (Anthropic)


What is the output?
So‘rovnoma
  •   2,4,6,8 1,2,3,4 1,2,3,4
  •   2,4,6 1,2,3 1,2,3,4
  •   2,4,6,8 1,2,3 1,2,3,4
  •   2,4,6 1,2,3 1,2,3
17 ta ovoz


CHALLENGE

const arr = [1, 2, 3];
const log = [];
const result = arr.map((x, i) => {
if (i === 0) arr.push(4);
log.push(x);
return x * 2;
});
console.log(result.join(','), log.join(','), arr.join(','));


What is the output?
So‘rovnoma
  •   1 2 1
  •   1 4 2
  •   2 2 2
  •   1 2 2
11 ta ovoz


CHALLENGE

class Counter {
#count = 0;
static #instances = 0;
constructor() { Counter.#instances++; }
#increment() { this.#count++; }
incrementAndGet() {
this.#increment();
return this.#count;
}
static get total() { return Counter.#instances; }
}

class SpecialCounter extends Counter {
incrementAndGet() {
return super.incrementAndGet() * 2;
}
}

const c1 = new Counter();
const c2 = new SpecialCounter();
console.log(`${c1.incrementAndGet()} ${c2.incrementAndGet()} ${Counter.total}`);

20 ta oxirgi post ko‘rsatilgan.