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
897

Showing posts older than #2495 Β· Back to latest

Older Posts 20 shown
Post #2493 4.76K
  • ❀ 5
  • πŸ”₯ 3
  • πŸ€” 3
  • πŸ‘ 1
Post #2492 4.7K
CHALLENGE

function Vehicle(wheels) {
this.wheels = wheels;
}

Vehicle.prototype.getWheels = function() {
return this.wheels;
};

function Car() {
Vehicle.call(this, 4);
this.doors = 4;
}

Car.prototype = Object.create(Vehicle.prototype);
Car.prototype.constructor = Car;

const myCar = new Car();
console.log(myCar.getWheels(), myCar instanceof Vehicle);
  • ❀ 6
Post #2491 4.22K
😏 CSS conditionals with the new if() function

From Chrome 137 you can try out CSS inline conditionals with the if() function. if() enables a cleaner developer interface for dynamic styles like style queries and media queries, with some key differences, which you can learn about in this post.
  • ❀ 10
  • πŸ‘ 4
  • πŸ”₯ 2
Post #2490 4.51K
  • ❀ 5
  • πŸ€” 3
  • πŸ‘ 2
Post #2489 4.45K
CHALLENGE

const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x);

const addTwo = num => num + 2;
const multiplyByThree = num => num * 3;
const subtractTen = num => num - 10;

const calculate = compose(subtractTen, multiplyByThree, addTwo);

console.log(calculate(5));
  • ❀ 5
  • πŸ”₯ 3
  • πŸ‘ 1
Post #2488 5K
🌲 You Don’t Know Node.js EventLoop

The Ultimate Guide to Understanding EventLoop in Node.js

This comprehensive guide is going to take some time to cover every detail that you need to know, so grab a cup of coffee and settle in for an exciting journey to the fascinating world of Node.js. Let’s get started!

nairihar
  • ❀ 8
  • πŸ‘ 3
  • πŸ”₯ 2
Post #2487 4.06K
  • 🀣 8
  • πŸ‘ 3
  • ❀ 2
  • πŸ€” 2
Post #2486 4.34K
CHALLENGE

function mystery() {
try {
console.log('A');
throw new Error('Oops');
console.log('B');
} catch (err) {
console.log('C');
return 'D';
} finally {
console.log('E');
return 'F';
}
console.log('G');
return 'H';
}

console.log(mystery());
  • ❀ 6
Post #2485 4.46K
✌️ Driver.js: Tours, Highlights, Contextual Help, and More

A vanilla JS library for making on-page tours and contextual help systems. It’s been around for several years, but is still maintained, and there are lots of examples to check out – it’s really smooth.

Kamran Ahmed
  • ❀ 3
  • πŸ‘ 3
  • πŸ”₯ 2
Post #2484 4.24K
  • πŸ”₯ 1
Post #2483 4.21K
CHALLENGE

const users = [
{ id: 1, name: 'Sarah' },
{ id: 2, name: 'Miguel' },
{ id: 3, name: 'Jordan' }
];

const activeUsers = new WeakSet();
activeUsers.add(users[0]);
activeUsers.add(users[2]);

users.splice(1, 1); // Remove Miguel

let count = 0;
for (const user of users) {
if (activeUsers.has(user)) count++;
}

console.log(count);
  • ❀ 5
  • πŸ”₯ 2
Post #2482 4.19K
✌️ What’s the Difference Between Ordinary Functions and Arrow Functions?

This sounds like basic stuff, but James always does a good job of digging in and explaining things in a way that gives you a more nuanced way to think about a concept, even if it’s just β€œWhich function declaration syntax should I use?”

James Sinclair
  • πŸ‘ 7
  • ❀ 2
  • πŸ”₯ 1
Post #2481 4.24K
  • ❀ 6
Post #2480 4.43K
CHALLENGE

function createCounter() {
let count = 0;

return {
increment() {
return ++count;
},
reset() {
const oldCount = count;
count = 0;
return oldCount;
}
};
}

const counterA = createCounter();
const counterB = createCounter();

counterA.increment();
counterA.increment();
counterB.increment();
const result = counterA.reset() + counterB.reset();
console.log(result);
  • ❀ 3
Post #2479 4.33K
  • ❀ 5
  • πŸ‘ 1
  • πŸ”₯ 1
Post #2478 4.48K
CHALLENGE

const memoryLeak = () => {
const cache = new Map();
const weakCache = new WeakMap();

const objKey = { id: 123 };
const data = { name: 'User data', value: 42 };

cache.set(objKey, data);
weakCache.set(objKey, data);

// Simulate removing reference to key
const result = { map: cache.has(objKey), weakMap: weakCache.has(objKey) };
// objKey = null; // This would be an error, as const can't be reassigned

return result;
};

console.log(memoryLeak());
  • ❀ 8
  • πŸ€” 2
Post #2477 4.39K
🟠Vercel Acquires NuxtLabs

Vercel has acquired the company that caretakes the Nuxt project and employs some of its core team – a move Vue creator Evan You is quite optimistic about. Vercel now manages, or at least supports, several key projects like Next.js, Turborepo, Svelte, and shadcn/ui. Nuxt itself remains open source and has a promising future. Vercel’s Guillermo Rauch shares a little more about the move here.

NuxtLabs / Vercel
  • ❀ 8
  • πŸ‘ 1
  • πŸ”₯ 1
Post #2476 4.32K
  • ❀ 3
  • πŸ‘ 3
  • πŸ€” 3
  • 🀣 2
Post #2475 4.43K
CHALLENGE

function createCounter() {
let count = 0;

function increment() {
count += 1;
return count;
}

function decrement() {
count -= 1;
return count;
}

return { increment, decrement, value: () => count };
}

const counter = createCounter();
counter.increment();
counter.increment();
counter.decrement();

console.log(counter.value() + counter.increment());
  • ❀ 4
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 β†’