javascript | Unsorted

Telegram-канал javascript - JavaScript

31615

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

Subscribe to a channel

JavaScript

🤨 ANSIS 4.0: ANSI Color Library for Everywhere

A library to use the power of ANSI escape sequences for coloring and styling text in many environments including the terminal, Chromium-based browsers, Node, Bun, Deno, and even Next.js. v4.0 is a big upgrade with enough breaking changes to warrant a migration guide for existing users.

webdiscus

Читать полностью…

JavaScript

🙏 To continue delivering more exciting stories, we're kindly asking telegram premium users to help us (boost) take things to the next level.

We need 40 boosts 😭

/channel/javascript?boost

Читать полностью…

JavaScript

🤔 I Think the Ergonomics of Generators is Growing on Me

The author notes generator functions have been widely available in JavaScript for a long time, yet “their practicality hasn’t exactly caught on.” This is a great look at what they are and where they can be useful.

Alex MacArthur

Читать полностью…

JavaScript

CHALLENGE

function modify(obj) {
obj.a.push(4);
obj.b = 'changed';
return obj;
}

const original = { a: [1, 2, 3], b: 'original', c: { deep: true } };
const copy1 = { ...original };
const copy2 = JSON.parse(JSON.stringify(original));

modify(copy1);
console.log(original.a, original.b, copy2.c === original.c);

Читать полностью…

JavaScript

🥶 Write Github Actions workflow files in TypeScript (compiles to YAML)

emmanuelnk

Читать полностью…

JavaScript

🤟 To ensure your Node.js version is secure, use:


npx is-my-node-vulnerable


A tool created and maintained by the Node.js security team. This utility allows you to quickly check for known vulnerabilities and helps safeguard your projects.

Читать полностью…

JavaScript

😆 True ...

It's just easy to start.

Читать полностью…

JavaScript

🥂 We Did It – 25K Subscribers!

We're excited to announce that our newsletter reached 25,000 subscribers! This was one of our biggest goals for 2024, and we couldn’t have done it without your amazing support.

Thank you for being part of this journey. We’ve got more exciting content coming, so stay tuned!

Читать полностью…

JavaScript

CHALLENGE ❓


const map = new Map();
const key1 = {};
const key2 = key1;

map.set(key1, "Value for key1");
map.set(key2, "Value for key2");

console.log(map.get({}));
console.log(map.get(key1));

Читать полностью…

JavaScript

CHALLENGE ❓


const obj = {};
Object.defineProperty(obj, 'name', {
value: 'Alice',
writable: false,
configurable: false
});

try {
obj.name = 'Bob';
delete obj.name;
console.log(obj.name);
} catch (e) {
console.log('Error:', e.message);
}

Читать полностью…

JavaScript

CHALLENGE ❓


function processData({ a = 10, b = 20 } = { a: 30 }) {
console.log(a, b);
}

processData({ a: 5 });
processData();

Читать полностью…

JavaScript

CHALLENGE ❓


function* numberGenerator() {
let i = 0;
while (i < 3) {
yield i++;
}
}

const gen = numberGenerator();
console.log(gen.next().value);
console.log(gen.return(10).value);
console.log(gen.next().value);

Читать полностью…

JavaScript

CHALLENGE ❓


const obj = Object.freeze({
name: "Alice",
info: {
age: 25
}
});

try {
obj.name = "Bob";
obj.info.age = 30;
} catch (e) {
console.log("Error:", e.message);
}

console.log(obj.name, obj.info.age);

Читать полностью…

JavaScript

CHALLENGE ❓


async function first() {
console.log('First Start');
await second();
console.log('First End');
}

async function second() {
console.log('Second Start');
}

console.log('Script Start');
first();
setTimeout(() => console.log('Timeout'), 0);
console.log('Script End');

Читать полностью…

JavaScript

CHALLENGE ❓


setTimeout(() => console.log('Timeout 1'), 100);

setTimeout(() => {
console.log('Timeout 2');
Promise.resolve().then(() => console.log('Promise in Timeout 2'));
}, 50);

Promise.resolve().then(() => console.log('Promise 1'));

setTimeout(() => console.log('Timeout 3'), 150);

console.log('Sync');

Читать полностью…

JavaScript

CHALLENGE

try {
const arr = [1, 2, 3];

function processArray() {
try {
nonExistentFunction();
} catch (err) {
throw new TypeError('Invalid type');
}
}

try {
processArray();
} catch (err) {
console.log(err instanceof Error, err instanceof TypeError, err.message);
}
} catch (finalError) {
console.log('Caught in outer block:', finalError);
}

Читать полностью…

JavaScript

🥃 We often get feedback asking us to include answers to the quizzes—but honestly, some of them need more explanation than a Marvel movie plot. It’s way better if you use Google or GPT to dig into the questions and uncover the answers like the true quiz detective you are!

Читать полностью…

JavaScript

CHALLENGE

const result = (function() {
let count = 0;

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

result.increment();
result.increment();
console.log(result.reset() + result.value + result.increment());

Читать полностью…

JavaScript

CHALLENGE

function processTransaction(amount) {
try {
if (typeof amount !== 'number') {
throw new TypeError('Amount must be a number');
}
if (amount <= 0) {
throw new RangeError('Amount must be positive');
}
return 'Transaction processed';
} catch (error) {
if (error instanceof TypeError) {
return { status: 'Type Error', message: error.message };
} else if (error instanceof RangeError) {
return { status: 'Range Error', message: error.message };
}
return { status: 'Unknown Error', message: error.message };
}
}

console.log(processTransaction(-50));

Читать полностью…

JavaScript

CHALLENGE


for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 100);
}

Читать полностью…

JavaScript

CHALLENGE ❓


const sym = Symbol('unique');
const obj = {
[sym]: 'Secret',
public: 'Visible'
};

console.log(Object.keys(obj));
console.log(obj[Symbol('unique')]);

Читать полностью…

JavaScript

CHALLENGE ❓


Promise.resolve(1)
.then(value => {
console.log(value);
throw new Error('Something went wrong');
})
.then(() => {
console.log('This will not run');
})
.catch(error => {
console.log('Caught:', error.message);
return 42;
})
.then(value => {
console.log('Recovered with:', value);
});

Читать полностью…

JavaScript

👀 The Story of Web Framework Hono, By Its Creator

Hono is a neat, lightweight framework designed to run on any JavaScript runtime that has been picking up steam in the past year. You can create a simple app reminiscent of Express.js, say, but run it on Cloudflare Workers, Deno, Bun, or Node. It’s in heavy use all over the place, and has lots of interesting features like letting you write HTML with JSX.

Yusuke Wada

Читать полностью…

JavaScript

🤟 Node v20.18.0 (LTS) Released; v20 'Iron' Prepares to Bow Out as Active LTS Release

It’s been a quiet few weeks for official releases. This update marks one of the last in Node 20’s run as the active LTS release, and introduces experimental network inspection support. Node 22 will soon take over the active LTS crown (as per schedule) but what will its codename be given there are no elements starting with J? Amazingly, this question was asked six years ago and it's (probably) going to be Jod.

Michaël Zasso

Читать полностью…

JavaScript

✌️ 10 New JS Features You Should Know About

Awesome

Читать полностью…

JavaScript

💻 Does Deno 2 really uncomplicate JavaScript?

Beyond Fireship

Читать полностью…

JavaScript

🔥 The WordPress ecosystem has lost its mind…

Читать полностью…

JavaScript

👀 DOCX 9.0: Generate Word .docx Files from JavaScript

The code to lay out documents is verbose but there’s a lot of functionality baked in and there aren’t many other options for this task. Here’s a CodePen-based example to give you an idea. GitHub repo.

Dolan Miu

Читать полностью…

JavaScript

✌️ TC39 Advances 10+ ECMAScript Proposals

The architects behind the development of the ECMAScript / JavaScript spec got together again this week (you can see them in this tweet) and they had a packed agenda. Import attributes, Iterator helpers, Promise.try and Regexp modifiers all made it to stage 4, and more besides.

Sarah Gooding (Socket)

Читать полностью…

JavaScript

CHALLENGE ❓


setTimeout(() => {
console.log('Timeout');
Promise.resolve().then(() => console.log('Promise after Timeout'));
}, 0);

Promise.resolve().then(() => console.log('Promise'));

console.log('End of script');

Читать полностью…
Subscribe to a channel