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
895

Showing posts older than #3024 · Back to latest

Older Posts 20 shown
Post #3023 2.81K
CHALLENGE


class Vehicle {
constructor(type) {
this.type = type;
}
describe() {
return `I am a ${this.type}`;
}
}

class Car extends Vehicle {
constructor(brand) {
super("car");
this.brand = brand;
}
describe() {
return `${super.describe()} made by ${this.brand}`;
}
}

const myCar = new Car("Toyota");

console.log(myCar.describe());
console.log(myCar instanceof Car);
console.log(myCar instanceof Vehicle);
console.log(Object.getPrototypeOf(Car) === Vehicle);
  • 👍 6
  • 🔥 5
  • ❤ 1
Post #3022 3.02K
✌️ Oxfmt Beta: A Fast, Rust-Powered JavaScript Code Formatter

A 100% Prettier-compatible JavaScript code formatter (and sister project of Oxlint) that boasts being 30x faster than Prettier and 3x faster than Biome. Since the alpha, it now supports embedded language formatting (JSX, YAML, HTML, etc), Tailwind CSS class sorting, import sorting, and more.

Boshen, Dunqing, and Sugiura (VoidZero)
  • 👍 6
  • ❤ 1
  • 🔥 1
Post #3021 2.82K
  • 👍 8
  • ❤ 4
Post #3020 3K
CHALLENGE

function testScope() {
var x = 'outer';
let y = 'outer';

if (true) {
var x = 'inner';
let y = 'inner';
console.log(x, y);
}

console.log(x, y);
}

testScope();
  • ❤ 5
  • 👍 5
  • 🔥 2
  • 🤣 2
Post #3019 3.08K
  • 👍 3
  • ❤ 2
Post #3018 3.1K
CHALLENGE

const user = {
name: 'Sarah',
profile: {
settings: {
theme: 'dark'
}
}
};

const config = {
name: 'John',
profile: null
};

console.log(user.profile?.settings?.theme);
console.log(config.profile?.settings?.theme);
console.log(user.profile?.preferences?.language);
console.log(config.profile?.settings?.theme ?? 'light');
  • 👍 5
  • 🔥 3
  • ❤ 2
Post #3017 3.23K
  • ❤ 6
  • 🔥 2
Post #3016 3.43K
CHALLENGE

const user = {
name: 'Sarah',
age: 25,
greet() {
return `Hello, I'm ${this.name}`;
}
};

const keys = Object.keys(user);
const values = Object.values(user);
const entries = Object.entries(user);

console.log(keys.length);
console.log(values.includes('Sarah'));
console.log(entries[2][0]);
  • 🔥 6
  • ❤ 4
  • 👍 2
Post #3014 3.72K
🤟 Halving Node.js Memory Usage with Pointer Compression

Does 50% memory savings in production sound good? Cloudflare, Igalia, and the Node project have collaborated on node-caged, a Docker image containing Node 25 with V8 pointer compression enabled. Matteo digs into all the details here – this is neat work, though there are tradeoffs to consider.

Matteo Collina
  • ❤ 9
  • 👍 5
  • 🔥 5
  • 🤩 1
Post #3013 3.63K
  • ❤ 8
  • 👍 3
Post #3012 3.32K
CHALLENGE

function createUser(name = 'Guest', age = 0, active = true) {
return { name, age, active };
}

const users = [
createUser('Sarah', 25),
createUser('Mike'),
createUser('Emma', undefined, false),
createUser(null, 30)
];

console.log(users.map(u => `${u.name}-${u.age}-${u.active}`).join('|'));
  • ❤ 3
  • 👍 2
Post #3011 3.58K
😬 Heroku, the cloud hosting/PaaS pioneer, has adopted a 'sustaining engineering model', with no new features in the pipeline. The dev community heard the 'death rattle' and migrate off heroku has joined many to-do lists.
  • 👍 6
  • 🔥 4
  • ❤ 3
Post #3009 3.36K
CHALLENGE

class CustomError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
}
}

try {
throw new CustomError("Something went wrong");
} catch (error) {
console.log(error.name);
console.log(error instanceof Error);
console.log(error instanceof CustomError);
console.log(typeof error.stack);
}
  • ❤ 8
  • 👍 7
  • 🔥 6
Post #3008 3.14K
This is how the new generation learns about the Node.js EventLoop 😂
  • ❤ 11
  • 👍 6
  • 🤣 4
  • 🔥 3
Post #3007 3.39K
⭐ Shades of Halftone is Maxime Heckel's grand tour of pixelation, dithering, and the creation of GLSL-powered halftone effects with React Three Fiber. An aesthetic increasingly popular in modern web design and digital art.
  • ❤ 5
  • 👍 5
  • 🔥 2
Post #3006 3.47K
  • ❤ 5
  • 🔥 3
  • 👍 2
Post #3005 3.23K
CHALLENGE

const cache = new Map();

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

const fibonacci = memoize((n) => {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
});

console.log(fibonacci(5));
console.log(cache.size);
  • ❤ 9
  • 👍 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 →