TGViewer
Channel Public Channel
JavaScript

JavaScript

@javascript

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
Subscribers
31.1K
Photos
1.2K
Videos
10
Links
894

Showing posts older than #3428 · Back to latest

Older Posts 20 shown
Post #3427 2.3K
👀 anydoc: Convert 14 Document Formats into Markdown

A Rust-powered library (with Node.js and WASM bindings) that converts Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, CSV, and PDF documents into Markdown. I tried it on a 1,600 page PDF and it took less than 2 seconds. There's also an in-browser demo to try it out. GitHub repo.

Firecrawl
  • 👍 3
  • 🔥 2
  • ❤ 1
Post #3426 2.23K
  • 👍 1
  • 🔥 1
Post #3425 2.18K
CHALLENGE

const arr = [1, 2, 3, 4, 5];
arr[Symbol.iterator] = function* () {
for (let i = 0; i < 3; i++) yield arr[i] * 2;
};
console.log([...arr], JSON.stringify(arr));
  • 👍 2
  • 🔥 2
  • ❤ 1
Post #3424 2.34K
🤟 Node.js 26.7.0 (Current) Released

Landing just two days after 26.6, coverage reports can now include files your tests didn't touch with --test-coverage-include-all, FFI and SQLite pick up crash fixes, and Perfetto tracing support lands, though you'll need a custom build to use it.

Antoine du Hamel
  • ❤ 4
  • 👍 4
  • 🔥 1
Post #3423 2.35K
  • ❤ 1
  • 👍 1
Post #3422 2.22K
CHALLENGE

class Money {
#amount;
constructor(amount) { this.#amount = amount; }
[Symbol.toPrimitive](hint) {
if (hint === 'number') return this.#amount;
if (hint === 'string') return `$${this.#amount}`;
return `Money(${this.#amount})`;
}
}
const m = new Money(42);
console.log(`${m}`, m + 8, m == 42);
  • ❤ 6
  • 🤩 3
  • 🔥 1
Post #3421 2.34K
↗️ TanStack Charts: A New Chart Grammar Option

In the past few weeks, TanStack has been rapidly iterating on a new, framework-neutral way to declaratively specify a large number of chart-related visualizations in JavaScript. Output renders to SVG or canvas and can be styled as you wish. Here's a comparison against other established options.

TanStack
  • ❤ 7
  • 👍 2
Post #3420 2.14K
  • ❤ 3
  • 👍 2
Post #3419 2.2K
CHALLENGE

const str = "2024-01-15";
const result = str.replace(/(\d+)-(\d+)-(\d+)/, "$3/$2/$1");
const s2 = "abc".padStart(6, "12");
const s3 = [..."hello"].reverse().join("");
console.log(result, s2, s3);
  • 👍 4
  • ❤ 2
  • 🔥 2
Post #3418 2.44K
👀 Next.js 16.3 Released

The newly expanded Next.js team (now including Dan Abramov and 𝕏 Pete Hunt!) has dropped the latest version of the popular React framework, complete with faster builds, optional TypeScript 7 type checking, faster SSR, Instant Navigations, AI improvements, and more.

The Next.js Team
  • 🤔 3
  • ❤ 2
Post #3417 2.24K
  • 🔥 2
  • ❤ 1
Post #3416 2.27K
CHALLENGE

function memoize(fn) {
const cache = new Map();
return (...args) => {
const key = JSON.stringify(args);
if (cache.has(key)) return cache.get(key);
const result = fn(...args);
cache.set(key, result);
return result;
};
}

let calls = 0;
const add = memoize((a, b) => { calls++; return a + b; });

const r1 = add(1, 2);
const r2 = add(2, 1);
const r3 = add(1, 2);
console.log(r1, r2, r3, calls);
  • ❤ 2
Post #3415 2.27K
  • ❤ 5
  • 👍 2
Post #3414 2.14K
CHALLENGE

const Loggable = {
log() { return `[${this.constructor.name}] ${this.toString()}`; }
};

class Base {
toString() { return 'Base instance'; }
}

Object.setPrototypeOf(Base.prototype, Loggable);

class Derived extends Base {
toString() { return 'Derived instance'; }
}

const b = new Base();
const d = new Derived();

console.log(b.log(), d.log(), Object.getPrototypeOf(Derived.prototype) === Base.prototype);
  • ❤ 6
  • 🔥 2
Post #3412 2.3K
CHALLENGE

class Config {
constructor(options = {}) {
this.retries = options.retries ?? 3;
this.timeout = options.timeout ?? 1000;
}
}
const cfg1 = new Config({ retries: 0, timeout: null });
const cfg2 = new Config({ retries: undefined, timeout: false });
cfg1.retries ??= 99;
cfg2.timeout ??= 99;
console.log(cfg1.retries, cfg1.timeout, cfg2.retries, cfg2.timeout);
  • ❤ 3
  • 🔥 1
Post #3411 2.4K
  • ❤ 6
  • 🤔 3
Post #3410 2.41K
CHALLENGE

let arr = [];
for (let i = 0; i < 3; i++) {
if (i === 1) {
let i = 10;
arr.push(i);
continue;
}
arr.push(i);
}
console.log(arr.join('-'));
  • ❤ 4
  • 🔥 4
  • 👍 3
Post #3409 2.53K
  • ❤ 5
  • 👍 3
Post #3408 2.25K
CHALLENGE

const a = [] + {};
const b = {} + [];
const c = 1 + '1' - 1;
const d = '5' + 3 - 2;
const e = true + true;
console.log(a, b, c, d, e);
  • ❤ 6
  • 👍 5
  • 🤣 3
  • 🔥 2
Older posts →
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →