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
31K
Photos
1.2K
Videos
10
Links
899

Showing posts older than #2153 Β· Back to latest

Older Posts 20 shown
Post #2152 5.52K
πŸ”Ž Node Modules Inspector

A tool that runs pnpm inside your browser, β€œinstalls” a package, then analyzes its dependencies. This can be useful for analyzing packages you already use, but also for simplifying your own projects, as 11ty’s Zach Leatherman did here.

Anthony Fu
  • ❀ 10
  • πŸ‘ 6
  • πŸ”₯ 1
Post #2151 5.25K
  • πŸ‘ 11
  • ❀ 3
  • πŸ”₯ 1
Post #2150 5.46K
CHALLENGE

function outer() {
let x = 10;

function inner() {
console.log(x);

if(true) {
let x = 20;
console.log(x);
}

console.log(x);
}

inner();
}

outer();
  • πŸ‘ 7
  • ❀ 1
Post #2149 5.12K
πŸ‘ PGlite: Run Postgres in WebAssembly

PGlite packages a WASM build of Postgres into a TypeScript library that can be run directly from Node.js (or Bun, Deno, and even the browser) and it’s only a few megabytes in size.

ElectricSQL / Neon
  • πŸ‘ 5
  • ❀ 3
  • πŸ”₯ 2
Post #2148 5.34K
  • πŸ‘ 5
  • ❀ 2
  • πŸ”₯ 2
Post #2147 5.39K
CHALLENGE

const userMap = new WeakMap();

const user1 = { name: 'Alice' };
const user2 = { name: 'Bob' };

userMap.set(user1, { visits: 10 });
userMap.set(user2, { visits: 5 });

// Later in the code...
const entries = [];
for (const obj of [user1, null, user2]) {
if (obj !== null && userMap.has(obj)) {
entries.push(userMap.get(obj).visits);
}
}

console.log(entries.reduce((sum, visits) => sum + visits, 0));
  • ❀ 5
  • πŸ”₯ 3
  • πŸ‘ 2
Post #2145 5.62K
  • πŸ”₯ 7
  • πŸ‘ 4
  • ❀ 3
Post #2144 5.5K
CHALLENGE

const company = {
name: 'TechCorp',
departments: {
engineering: {
head: { name: 'Alice', contact: null },
staff: 50
},
marketing: null
}
};

const engineeringContact = company.departments.engineering.head.contact;
const marketingHead = company.departments.marketing?.head?.name;
const financeStaff = company?.departments?.finance?.staff ?? 'Not available';

console.log(`${engineeringContact} - ${marketingHead} - ${financeStaff}`);
  • πŸ‘ 10
  • 🀩 2
  • ❀ 1
Post #2142 5.6K
  • πŸ‘ 6
  • ❀ 2
  • πŸ”₯ 2
Post #2141 5.46K
CHALLENGE

function Animal(name) {
this.name = name;
}

Animal.prototype.speak = function() {
return `${this.name} makes a noise`;
};

function Dog(name) {
Animal.call(this, name);
}

Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;

Dog.prototype.speak = function() {
return `${this.name} barks`;
};

const animal = new Animal('Animal');
const dog = new Dog('Rex');

console.log(dog instanceof Animal);
  • πŸ”₯ 5
  • πŸ‘ 1
Post #2139 5.67K
  • πŸ€” 5
  • ❀ 2
  • πŸ‘ 1
Post #2138 5.54K
CHALLENGE

const user = {
profile: {
name: "Alice",
settings: null
},
getPreferences() {
return this.profile.settings?.theme || "default";
}
};

const admin = {
profile: {
name: "Admin"
},
getPreferences() {
return this.profile.settings?.theme || "default";
}
};

console.log(user.getPreferences());
console.log(admin.getPreferences());
console.log(user.profile.extra?.id?.toString());
  • πŸ‘ 7
  • ❀ 5
Post #2137 5.23K
✌️ A Report on How the Web is Really Using JavaScript

Each year, the HTTP Archive puts together the Web Almanac, a report on the β€˜state of the Web’. The JavaScript section has just gone live and goes into depth on how much JS we’re using (or failing to use!), the popularity of TypeScript, loading methods, Web Worker use, and, yes, jQuery still leads the way!

HTTP Archive
  • πŸ‘ 5
  • ❀ 4
  • πŸ€” 2
  • πŸ”₯ 1
Post #2136 5.26K
  • πŸ”₯ 4
  • ❀ 3
  • πŸ‘ 1
Post #2135 5.62K
CHALLENGE

function* counter() {
let count = 1;
while (true) {
const reset = yield count;
count = reset ? 1 : count + 1;
}
}

const gen = counter();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next(true).value);
console.log(gen.next().value);
  • πŸ‘ 8
  • πŸ”₯ 4
  • ❀ 1
Post #2134 5.88K
πŸ€” TanStack Form v1.0: Headless, Type-Safe Form State Management

A type-safe, framework agnostic (React, Vue, Angular, Solid and Lit are all supported out of the box), headless and isomorphic way to create and work with forms, with this v1.0 release over two years in the making. If you already use things like Formik or React Hook Form and are wondering how it differs, here’s a comparison table.

Tanner Linsley
  • ❀ 3
  • πŸ”₯ 3
  • πŸ‘ 2
Post #2133 5.37K
  • ❀ 4
  • πŸ”₯ 4
  • πŸ‘ 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 β†’