r/JSdev • • Nov 30 '23

2023 Jetbrains Survey

0 Upvotes

Interesting that JS lost 3% in popularity while TypeScript is gaining popularity. I think this statistic is misleading since both are going to end up targeting the same codebase.

You could have the same amount of code base when all repos switch to TypeScript having 0 usage of JS… what does that means you think?


r/JSdev • • May 27 '23

[AskJS] Frameworkless, functional javascript discord/matrix community?

Thumbnail
self.javascript
0 Upvotes

r/JSdev • • Jul 13 '22

Invariant - a helpful JavaScript pattern

Thumbnail
strictmode.io
0 Upvotes

r/JSdev • • Apr 26 '21

How do we best prevent these kinds of bugs?

Thumbnail
gallery
0 Upvotes

r/JSdev • • Oct 06 '26

Your JSON Is Lying to You

Thumbnail
blog.gaborkoos.com
0 Upvotes

r/JSdev • • Apr 08 '23

You’ve Got Options for Removing Event Listeners

Thumbnail
macarthur.me
0 Upvotes

r/JSdev • • Jan 23 '23

JavaScript Test Snippets - VS Code Extension

Thumbnail marketplace.visualstudio.com
0 Upvotes

I've written a VS Code extension that generates code snippets for the 3 big testing frameworks: Jest, Jasmine and Mocha. Would love some feedback on it, usability or code wise.

I'd like to add Sinon and chai.js support too.


r/JSdev • • Mar 25 '22

Why there is no synchronous function for sleep in JavaScript?

0 Upvotes

I had been working on python for long time and using JS for past 3 years only. When ever I work on some task that require to wait, I have use async function then setTimeout with promise to make it sleep for certain ms.

Why there is no synchronous sleep function like time.sleep(seconds) in python or sleep()/usleep() in libc.so?


r/JSdev • • Mar 15 '22

JavaScript interview prep

0 Upvotes

Hi Guys,

I have tried to collate most of the questions asked to me during interviews in this app - https://play.google.com/store/apps/details?id=gamesmint.com.jsone . Could you guys be kind enough to give it a try and some feedback?

Thanks in advance.


r/JSdev • • Dec 02 '21

Enforce subtraction to have 2 decimal places only

0 Upvotes

Currently, I am using the following method to enforce the 2 digit precision in multiple files. Is there any clear and shorter syntax to do that?

 // calculate block
 const shares = parseFloat((amount / recentShare.amount).toFixed(2));

PS: Please don't say create a utility function


r/JSdev • • Nov 13 '21

Foundations of Web

Thumbnail
pushparaja.hashnode.dev
0 Upvotes

r/JSdev • • Mar 01 '26

Java script

Post image
0 Upvotes

назовите ваши любимые команды


r/JSdev • • Sep 24 '21

Building A Custom Audio Library With JavaScript

Thumbnail
youtube.com
0 Upvotes

r/JSdev • • Feb 02 '24

Help me to fix this!!!

0 Upvotes

I was creating code for fetching content from a novel site and convert it to epub.

But site required cloudflare captcha solving, so I am sending cookies with it too.

code :

import fetch from "node-fetch";
import * as cheerio from "cheerio";
import fs from "fs";
import dotenv from "dotenv";
dotenv.config();
const userAgent = process.env.USER_AGENT;
const cookie = process.env.COOKIE;
const host = process.env.HOST;
const accept = process.env.ACCEPT;
const URL = "https://www.lightnovelworld.com";
let path = "/novel/the-steward-demonic-emperor-892/chapter-1-30041322";
const novelChapters = [];
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function chapter() {
try {
const response = await fetch(URL + path, {
headers: {
"User-Agent": userAgent,
Cookie: cookie,
Host: host,
Accept: accept,
Referer: URL,
},
});
if (!response.ok) {
throw Error(\Error: ${response.status} ${response.statusText}`);}await delay(2000); // delayconst body = await response.text();const $ = cheerio.load(body);const chapterTitle = $(".chapter-title").text(); // fetching titleconst chapterContent = $("#chapter-container"); // Selecting the chapter container`

// Removing ad-related elements
chapterContent.find(".chapternav").remove();
// Additional cleanup if needed
const advertisementDiv = chapterContent.find(".vm-placement");
for (let i = 0; i < advertisementDiv.length; i++) {
const parentDiv = advertisementDiv.eq(i).closest("div");
parentDiv.remove();
}
novelChapters.push({
chapterTitle,
chapterContent,
});
const nextChapter = $("button.nextchap"); // to find next chapter link
if (nextChapter.length > 0) {
const nextChapterClasses = nextChapter.attr("class");
if (nextChapterClasses && nextChapterClasses.includes("isDisabled")) {
path = "";
return false;
}
}
path = nextChapter.attr("href"); // updating path for next chapter
return true;
} catch (error) {
console.error("Error in loadChapter", error);
throw error; // Re-throw the error to propagate it to the higher level
}
}
async function forAllChapters() {
try {
let next = await chapter();
while (next) {
await delay(3000);
next = await chapter();
}
console.log("DONE!!!");
} catch (error) {
console.error("Error in forAllChapters", error);
throw error; // Re-throw the error to propagate it to the higher level
}
fs.appendFileSync(
"novelChapters.txt",
JSON.stringify(novelChapters, null, 2)
);
}
forAllChapters().catch((error) => console.log(error));

But there is an error:

node index ─╯

Error in loadChapter Error: Error: 403 Forbidden

at chapter (file:///.../Documents/learn%20scrapping/index.js:31:13)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async forAllChapters ((file:///.../Documents/learn%20scrapping/index.js:77:16)

Error in forAllChapters Error: Error: 403 Forbidden

at chapter ((file:///.../Documents/learn%20scrapping/index.js:31:13)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async forAllChapters (f(file:///.../Documents/learn%20scrapping/index.js:77:16)

Error: Error: 403 Forbidden

at chapter ((file:///.../Documents/learn%20scrapping/index.js:31:13)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async forAllChapters ((file:///.../Documents/learn%20scrapping/index.js:77:16)

I know it is happening because site is detecting script and that's why 403 is the response?

Any way to fix it?