JavaScript
32K subscribers
1.02K photos
9 videos
33 files
705 links
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
Download Telegram
1🔥10👍4🤣43
👀 A neat way to find and tidy unused stuff in your projects

Knip finds unused files, dependencies and exports in your JavaScript and TypeScript projects. Less code and dependencies lead to improved performance, less maintenance and easier refactorings.

webpro-nl
Please open Telegram to view this post
VIEW IN TELEGRAM
👍53🔥2🤔1
CHALLENGE

console.log('A');

setTimeout(() => console.log('B'), 0);

Promise.resolve()
.then(() => {
console.log('C');
return Promise.resolve();
})
.then(() => console.log('D'));

console.log('E');
1👍1
👍154🔥2🤔2
🤟 Transformers.js v3: Now You Can Run Transformers in Node.js

A JavaScript port of Hugging Face’s transformers Python library that makes it possible to run natural language, vision, and audio machine learning models. v3 adds WebGPU support and now supports Node (plus Deno and Bun) as well as the browser. 1200+ models are ready to run in areas like embeddings, text generation, and speech recognition (as with whisper-small).

Hugging Face
Please open Telegram to view this post
VIEW IN TELEGRAM
9👍5🔥4
CHALLENGE

function memoize(fn) {
const cache = {};
return (arg) => cache[arg] ?? (cache[arg] = fn(arg));
}

const square = memoize((n) => n * n);

console.log(square(5));
console.log(square(5));
console.log(square(6));
👍6🔥1
👍84🔥4
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥7👍32
CHALLENGE

const obj = { a: 10 };
console.log(obj.a && obj.b || 20);
👍2
What is the output?
Anonymous Quiz
17%
10
49%
20
23%
undefined
11%
Error
👍9🔥7🤔32
Please open Telegram to view this post
VIEW IN TELEGRAM
👍43🔥1
CHALLENGE

const a = false || 0 || "" || null || "JavaScript";
console.log(a);
🔥5👍3
What is the output?
Anonymous Quiz
13%
null
25%
false
9%
""
54%
JavaScript
🤔23🔥12👍83
this was in 2017, and it was only for the landing page
🤣34👍62🤔2🤩2
CHALLENGE

function Person(name) {
this.name = name;
this.sayName = () => console.log(this.name);
}

const person1 = new Person('David');
const person2 = { name: 'Not David', sayName: person1.sayName };

person2.sayName();
👍7🔥1
What is the output?
Anonymous Quiz
32%
Not David
46%
David
16%
undefined
6%
Error
👍11🔥94🤣1
🌪 Python Jumps to #1 on GitHub Over JavaScript, But...

GitHub Universe took place this week, flooding us with data about how folks are using the platform. Of interest to those on social media was that Python has taken JavaScript's #1 language crown, though many argued that TypeScript (now #3) made an impact here. In positive news, JS still ranks first for code pushes alone and there's been a 15% jump in npm package consumption in the past year.

GitHub
Please open Telegram to view this post
VIEW IN TELEGRAM
👍13🤔81
CHALLENGE

const factorial = (function () {
const cache = {};
return function inner(n) {
if (n in cache) return cache[n];
return (cache[n] = n <= 1 ? 1 : n * inner(n - 1));
};
})();

console.log(factorial(5));
console.log(factorial(5));
🤔8🔥5👍4
What is the output?
Anonymous Quiz
53%
120, 120
20%
120, undefined
12%
Error
15%
5, 5
🤔10👍7🔥61
🌲 Tinybench 3.0: A Tiny, Simple Benchmarking Library

Uses whatever precise timing capabilities are available (e.g. process.hrtime or peformance.now). You can then benchmark whatever functions you want, specify how long or how many times to benchmark for, and get a variety of stats in return. GitHub repo.

Tinylibs
Please open Telegram to view this post
VIEW IN TELEGRAM
👍72🔥2
CHALLENGE

const obj = { value: 10 };
const result = (obj.value += 5) && obj.value;
console.log(result);
👍2