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 #3166 · Back to latest

Older Posts 20 shown
Post #3165 2.43K
CHALLENGE


const partial = (fn, ...presetArgs) => {
return function partiallyApplied(...laterArgs) {
return fn(...presetArgs, ...laterArgs);
};
};

const calculateTax = (taxRate, discount, price) => {
const discounted = price - (price * discount) / 100;
return parseFloat((discounted + (discounted * taxRate) / 100).toFixed(2));
};

const withVAT = partial(calculateTax, 20);
const withVATandDiscount = partial(withVAT, 15);

console.log(withVAT(0, 100));
console.log(withVATandDiscount(200));
console.log(partial(calculateTax, 10, 5)(50));
  • 👍 2
  • ❤ 1
  • 🔥 1
Post #3164 2.31K
😉 Evan You's State of Vue 2026 Talk

A month ago, Evan You (of Vue.js and VoidZero fame) gave his annual address. Less Vue-focused than usual (though Vapor Mode is “almost ready”), the talk focuses on Vite-ecosystem updates covering Vite 8, Vite+, and Void.

Evan You / Vue.js Amsterdam
  • ❤ 5
  • 👍 3
  • 🔥 2
Post #3163 2.35K
  • ❤ 5
  • 👍 2
Post #3162 2.38K
CHALLENGE

const counter = (function () {
let count = 0;
const history = [];

return {
increment(step = 1) {
count += step;
history.push(count);
return this;
},
decrement(step = 1) {
count -= step;
history.push(count);
return this;
},
getHistory: () => history,
getCount: () => count,
};
})();

counter.increment(5).increment(3).decrement(2);

console.log(counter.getCount(), counter.getHistory().join(" -> "));
  • ❤ 5
  • 👍 1
Post #3161 2.29K
😮 HyperFrames: Write HTML and JavaScript to Create Videos

An open-source framework for creating and rendering videos with HTML and JavaScript. Essentially a simpler non-React alternative to Remotion. It includes a variety of built-in blocks/components for common video effects and elements, and can also composite existing video and audio clips. GitHub repo.

HeyGen
  • ❤ 6
  • 🔥 2
Post #3159 2.38K
CHALLENGE

const user = {
profile: {
name: "Marcus",
score: 0,
nickname: null,
bio: undefined,
},
};

user.profile.nickname ??= "Anonymous";
user.profile.bio ??= "No bio provided";
user.profile.score ??= 100;
user.profile.rank ??= "Beginner";

const { name, score, nickname, bio, rank } = user.profile;
console.log(`${name} | ${score} | ${nickname} | ${bio} | ${rank}`);
  • ❤ 3
  • 🔥 2
Post #3158 2.31K
👀 Windows 95 as an Electron App

A full Windows 95 experience as an app on macOS, Linux, and Windows, built upon the v86 JavaScript + WASM emulator. v5.0 is a big release as you can mount a folder from your machine into it as a Z: drive, mount ISOs as CD-ROMs, there’s a shared clipboard, and Internet access has been improved. I’m so trying to get Microsoft Encarta’s Mindmaze running on this…

Felix Rieseberg
  • ❤ 9
  • 🔥 6
  • 👍 1
Post #3157 2.17K
  • ❤ 4
  • 👍 2
Post #3156 2.22K
CHALLENGE

class Animal {
#sound;

constructor(name, sound) {
this.name = name;
this.#sound = sound;
}

speak() {
return `${this.name} says ${this.#sound}`;
}

static create(name, sound) {
return new this(name, sound);
}
}

class Dog extends Animal {
#tricks = [];

constructor(name) {
super(name, "woof");
}

learn(trick) {
this.#tricks.push(trick);
return this;
}

perform() {
return `${this.name} performs: ${this.#tricks.join(", ")}`;
}
}

const rex = Dog.create("Rex", "bark");
rex.learn("sit").learn("shake").learn("roll over");

console.log(rex.speak());
console.log(rex.perform());
console.log(rex instanceof Animal);
console.log(rex instanceof Dog);
Post #3155 2.33K
🤔 Boneyard: Auto-Generated Skeleton Screens for Your UI

Snapshots your real UI and captures a flat list of skeleton ‘bones’ which are positioned, sized rectangles that mirror the page exactly. Supports React, Preact, React Native, Vue, Svelte, and Angular.

0xGF
  • ❤ 4
  • 👍 4
  • 🤔 1
Post #3154 2.39K
  • 🤔 11
  • ❤ 2
  • 🔥 2
Post #3153 2.38K
CHALLENGE

const values = [0.1 + 0.2, NaN, Infinity, -0, 42.6789];

const results = values.map((v, i) => {
if (i === 0) return Number.isInteger(v) + " " + v.toFixed(1);
if (i === 1) return Number.isFinite(v) + " " + Number.isNaN(v);
if (i === 2) return Number.isFinite(v) + " " + isFinite(v);
if (i === 3) return Object.is(v, -0) + " " + (v === 0);
if (i === 4) return v.toPrecision(4) + " " + Math.trunc(v);
});

results.forEach(r => console.log(r));
  • ❤ 1
  • 👍 1
  • 🔥 1
Post #3152 2.51K
🌕 Installing Every Firefox Extension

One person’s entertaining and heroic tale of wielding JavaScript to explore the Firefox extension ecosystem. And what oddities there are within! I enjoyed this a lot, it’s like Alice in Wonderland for developers. More spelunking like this please.

Jack Cab
  • ❤ 4
  • 🔥 4
  • 👍 3
  • 🤣 2
  • 🤔 1
  • 🤩 1
Post #3151 2.4K
  • ❤ 2
  • 🤔 1
Post #3150 2.53K
CHALLENGE

const prefix = 'user';
const id = 42;
const role = 'admin';

const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1);

const profile = {
[`${prefix}_${id}`]: 'Marcus',
[Symbol.iterator]: null,
[`get${capitalize(role)}`]: () => 'full-access',
[`${prefix}Count`]: 3,
};

const dynamicKey = `${prefix}_${id}`;

console.log(
profile[dynamicKey],
profile[`get${capitalize(role)}`](),
profile[`${prefix}Count`] * id,
Object.keys(profile).length
);
  • ❤ 2
Post #3149 2.29K
😮 Under the Hood of MDN's New Frontend

The hugely useful MDN has rebuilt its frontend stack from the ground up, ditching React for web components and a homegrown server component system. A great read on building a modern, content-heavy site without shipping unnecessary JavaScript on every page.

Leo McArdle (MDN)
  • ❤ 9
  • 🔥 2
  • 👍 1
Post #3148 2.25K
  • 👍 3
  • ❤ 2
  • 🔥 1
Post #3147 2.28K
CHALLENGE


const p1 = new Promise((resolve) => {
console.log("A");
resolve("B");
});

const p2 = p1.then((val) => {
console.log(val);
return "C";
});

p2.then((val) => {
console.log(val);
});

console.log("D");
  • 🔥 1
Post #3146 2.12K
  • 👍 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 →