/r/javascript
Chat about javascript and javascript related projects. Yes, typescript counts. Please keep self promotion to a minimum/reasonable level.
All about the JavaScript programming language.
Specifications:
Resources:
Related Subreddits:
/r/javascript
Hi everyone,
I’ve just released a package: env-protector
. It’s a tool I built to help with validating environment variables in Node.js applications, especially with TypeScript support.
In many Node.js projects, environment variables are crucial, but handling them can be error-prone. I found that:
So, I decided to create env-protector
to simplify this process. It offers:
string
, number
, boolean
, url
, email
, etc.).If you’ve ever struggled with managing and validating environment variables in your Node.js projects, this tool might be useful for you!
🔗 NPM Package: env-protector on npm
💻 GitHub Repo: env-protector GitHub
https://github.com/tc39/proposal-signals https://www.npmjs.com/package/@lit-labs/signals
Lit has implemented signals in labs, but I want to use signals in vanilla JS.
I want to do a project with electron, but I don't know how to manage the data, I like pocketbase for the authentication, file storage and realtime but every time I have to use it I have to use the command “pocketbase serve” and it is not comfortable for the end user, maybe use sqlite or what other option do you recommend, if sqlite which package or which client do you recommend?
I would like that the end user does not have to configure anything, just install a . exe and that's it.
Node.js' node:wasi
modules includes disclaimers such as
The node:wasi module does not currently provide the comprehensive file system security properties provided by some WASI runtimes. Full support for secure file system sandboxing may or may not be implemented in future. In the mean time, do not rely on it to run untrusted code.
and
The current Node.js threat model does not provide secure sandboxing as is present in some WASI runtimes.
While the capability features are supported, they do not form a security model in Node.js. For example, the file system sandboxing can be escaped with various techniques. The project is exploring whether these security guarantees could be added in future.
I’m working on a data processing feature for a React application. Previously, this process froze the UI until completion, so I introduced chunking to process data incrementally. While this resolved the UI freeze issue, it significantly increased processing time.
I explored using Web Workers to offload processing to a separate thread to address this. However, I’ve encountered a bottleneck: sharing data with the worker via postMessage
incurs a significant cloning overhead, taking 14-15 seconds on average for the data. This severely impacts performance, especially when considering parallel processing with multiple workers, as cloning the data for each worker is time-consuming.
postMessage
clones the objects, leading to delays.Any insights, best practices, or alternative approaches would be greatly appreciated!
Hi folks,
I'm forced to maintain an Xbox app written in JavaScript(WinJS) that runs on the internal EdgeHTML Chakra engine of Xbox (based on IE10). The app currently uses WinJS, which is now obsolete.
I’m planning to gradually rewrite the UI with a modern, fast library that:
I’ve been considering React 16.8 or 17, but I’m concerned it might slow things down on IE10. Ideally, I want something with React’s cleanliness but optimized for performance on IE10. It doesn't have to be React but It has to be modern. WebComponents is not an option as its not properly supported in IE10 more so on this lobotomized IE10.
Any recommendations or advice? Thanks in advance!
Are there senior programmers who's first (and maybe only) language is JS/TS.
I started with JS as a first language, so I built all my knowledge around it. Mostly I'm interested in backend and node. I'm at the point where I want to build knowledge about software design, and as I don't know any other language, the problem is I always see resources/books about oop, patterns, architecture and so on utilising Java or C# or other typed language with OOP paradigm.
Software design is not about the language, and there are even resources for JS/TS, but the way things implemented in JS world are different from more traditional languages.
And I have doubts if I learn it only JS way, I will always have an impostor syndrome.
So basically the question, are there successful developers (backend) without background in any other language before JS, and how you got your Software Design knowledge. And can you easily transfer it to other languages?
Did you find or create something cool this week in javascript?
Show us here!
Like those objects with values and even property names computed on the fly, but take it a step further. None of the supposed fields of the object exist in memory yet, and only when you access them they are evaluated and created on the object once.
For a simple example:
You expect a function to return an array with a step condition, so it would be something like [0,2,4,6,8,10]
for a step = 2
. We don't actually have to store all the indeces in memory (could be thousands of numbers). We could have an object that appears to have obj[2] as 4
or obj[4] as 8
or obj[7] as undefined (not created)
while we really only create those properties when we look at them.
The object will be very ligthweight even with thousands of expected properties, it will trade speed of intant access to predefined properties for memory efficiency of literally not having those properties untill you need each of them, could be used in phone apps.
Edit: computed, not evaluated properties, so far I don't know how to compute properties for generic objects in order to lazily evaluate them.
Edit2: by storing only important information of a predictable sequence we can remove 2 things:
While still maintaining the ability to access random parts of the sequence as if it were present.
After getting some examples from Ruby I went from using a Proxy
to using a class with a method.
I have done some measuring at length 1000 for getting a property in a loop and adding it to a variable:
I'd say this is an acceptable speed loss in favour of not creating upfront and storing the entire sequence, takes less memory to keep and less time to initialize. Of course such an abstraction so far only works on predictable sequences.
Hi guys,
So I'm working as an intern using my own laptop. I use VSCode for my company's codes. I heard about the free non-commercial version of WebStorm being release about a month ago and started using it. But recently it's crashing a lot and also crashed my windows a few times also.
Also recently I started working with BUN. Is that probably causing issues?
So what I want to get suggestion is about a whole new code editor or another method such that I can split the VSCode into two modes, work / personal.
Windows suggestions please.
*If mac suggestions are there please give them also as I'm planning a buy a second hand one. PS: BTW what do you guys think about second hand macs.
Hi everyone,
I’m a newbie when it comes to web development, though I have programming experience. I’m diving into web development and want to learn how to create small landing pages with 3D components and animations.
Here’s what I’ve been considering so far:
I’m debating whether I should go with Astro/Vite or Next.js as my framework. I’m fairly confident about sticking with React Three and Fiber for the 3D elements.
What are your thoughts? Any insights or suggestions would be appreciated!
Thanks! 🙌
Hello people. I consider myself a backend developer, but I have to write a lot of JS as well. As an outsider of the JS trends, I am wondering if there is any update on the use (or not) of the semi-colon to set the end of the command.
Are you still adding them? Yes, no, why?
Thanks
Hey everyone!
So I recently began working on a 2-in-1 Soccer News & Player Profiles API – an API where people can access player profiles AND the latest soccer news from trusted sources, like AP News, FIFA, Goal, ESPN, CBS Sports and more in an instant.
It's a REST API, and offers full support for creating, reading, updating, and deleting player profiles. In that regard, whether you're building a simple player database or a complex application, you can seamlessly manage every aspect of player data with the API's comprehensive CRUD capabilities.
I made it out of Node.js, but I'm unsure if I should continue using it for future projects due to being more proficient in Python than Node.js. What makes Node.js better than Python, and in what scenarios is it typically preferred over Python?
I'm thinking of writing an eBook on JavaScript aimed at mitigating common JavaScript pain points for beginners and demystifying what's actually simple.
Newbies: what are you struggling to learn at the moment?
Hello programmers,
I have a question for the community. I am looking for some input into whether I should learn JavaScript or Dart as a first programming language. I am mainly looking to learn to develop apps in th far future, and maybe pick up some freelance work after I get some experience.
I am trying to decide if Dart/Flutter or JavaScript/React Native is the better first set of language and tool to learn before I totally dive in.
I know FreeCodeCamp and Odin Project have great tools for learning JavaScript, and I do have a book on Dart. Any input is appreciated!