Questions tagged [javascript]

JavaScript (not to be confused with Java) is a high-level, dynamic, multi-paradigm, weakly-typed language used for both client-side and server-side scripting. Use this tag for questions regarding common implementations of ECMAScript, JavaScript, JScript, etc. JS does not typically refer to its ECMA-cousin, ActionScript.

Filter by
Sorted by
Tagged with
-4 votes
1 answer
93 views

Is named return good feature for programming language [closed]

I design my own general purpose hobby language right now. I want to implement named returns feature. Here is example of JS code, which looks like named return. const sumAndMinus = (num1, num2) => { ...
user avatar
  • 1
-3 votes
0 answers
22 views

Best approach for running Node modules in-browser [closed]

I'm building a browser-based tool for rapidly developing scripts in Javascript. As such, it would be highly desireable to use Node modules (i.e. crypt, etc.) in the browser. I'd prefer not to have to ...
user avatar
  • 95
-1 votes
0 answers
24 views

Good / Better / Best Practices with JS Comments [duplicate]

Looking for some tips with commenting on JS files, trying to improve process where I can. I maintain and update a business application as a sole developer. It is widely used but not publicly ...
user avatar
0 votes
0 answers
44 views

Svelte & Vite Project - where/how to define constant values?

I have project where I use a url in various places. To prevent having to change it in all places, I would like to define it as a constant value in just one place which is referenced everywhere. But I'...
user avatar
  • 101
1 vote
1 answer
58 views

Would invisible custom elements make sense?

The use case I was thinking about was something like this. I want to make a calendar for a month as a custom element, and I don't think passing up all the event data as JSON or something is the best ...
user avatar
0 votes
0 answers
15 views

Effective cache solution to have the newest data in React Native

Goal We have an app with different articles. I want to cache an article when the user has read it, but make sure that I display the latest data. I came up with this hook: React.useEffect(() => { ...
user avatar
  • 101
5 votes
2 answers
525 views

Is "this" in JavaScript out of fashion?

I'm not a frontend dev, but I recall that a few years ago, the this keyword was commonplace in frontend codebases. In recent years, I haven't seen this get used anymore. In the last few frontend ...
user avatar
  • 168
0 votes
1 answer
74 views

Verbs in Use Case name "Create User" [closed]

I'm struggling on how to name classes for use cases. Because I know that is "bad" to use verbs in classes names(Uncle Bob) but at the same time names of use case classes should explain what ...
user avatar
0 votes
0 answers
37 views

JavaScript: My logic traversing multi-dimensional arrays

Consider the following: Let's say below is the multi-dimensional, and you are given the starting point of [2, 2]. const WORLD = [ ['P', 'P', 'P', 'C', 'P'], ['P', 'M', 'P', 'C', 'P'], ...
user avatar
0 votes
2 answers
75 views

How to authenticate front end with backend in an anonymous user flow [closed]

I have an API that will be exposed on the internet publicly, the primary use of this API will be initially by a ReactJs front end but in the future we'd be looking to open this up to other clients ...
user avatar
  • 161
0 votes
0 answers
32 views

Rule of thumb for responsibilities in Vue projects

I'm using Vue3 with the composition API and Pinia. I want to avoid tight coupling but sometimes I don't know the best place for the logic. To give you some examples, I'm choosing Minesweeper ( I hope ...
user avatar
0 votes
3 answers
85 views

Should we test private data (static objects in this case) to make sure it maintains its structure?

I had a discussion at work about whether to unit test a private static object we're using as data for a public component. const data = { 45: { name: 'John' }, 2: { name: 'Patricia' }, 27: { name: '...
user avatar
4 votes
3 answers
1k views

How do you 'merge' several JS files into one? [closed]

New Web Dev here. Recently I got into DOM manipulation with JS, everything was sweet with one-page websites, but then I tried with projects with many html files and that's when I got confused. It's a ...
user avatar
-2 votes
1 answer
64 views

Creating a promise based API, from a message based API

I'm building some software that behind the scenes needs to communicate with hardware via a "message" API, over a named pipe. For example, I can send this message: <?xml version="1.0&...
user avatar
  • 115
0 votes
2 answers
195 views

Should a client / server share error codes?

I am in two minds about sharing client / server errors codes. We are writing both ends of the system, if our API was external this would not be possible, but that requirement is very unlikely. So an ...
user avatar
  • 151
0 votes
0 answers
25 views

Managing user session state with Google Sign In

I need some help with my authentication design. Happy to share any code as needed... Overview I have implemented the Google Sign-in (new web implementation here) button in my client web application. ...
user avatar
0 votes
1 answer
46 views

NextJs Explanation on Ecommerce and Other Project Implementation [closed]

I'm attempting to create a project to increase and enhance my coding skills, and I've lately migrated React to Nextjs. I've noticed that NextJs' main point or strength is rendering; Could someone ...
user avatar
0 votes
2 answers
168 views

Sharing logic / services across modules in "clean" architecture [closed]

I am trying to implement a layered architecture consisting of; Controller, Service, Repository, Entity. Each module has at least some of the above layers. I am often finding that modules need to share ...
user avatar
  • 151
-1 votes
1 answer
118 views

How to use external validation libraries for entities in a "clean" architecture?

I would like to make use of a external library to parse the core domain entities. Doing this in a naive way it would look like the following: import { z } from 'zod'; const Audience = z.object({ ...
user avatar
  • 151
1 vote
1 answer
84 views

How do I share translations between a .NET application and a react application?

I currently have two applications where one is a landing page (built in react) and another is a web page that lets users explore data (Written in ASP.NET 4.7). I'm currently using resx files to handle ...
user avatar
  • 121
0 votes
1 answer
82 views

Javascript and payment security

I'm using a third party CRM application which allows you to build web forms using drag and drop widgets and the ability to add javascript code to manipulate those widgets. I need to build a form to ...
user avatar
  • 291
40 votes
6 answers
11k views

In JavaScript, how is awaiting the result of an async different than sync calls?

I'm having a hard time wrapping my head around the use of async/await and regular sync function calls in JavaScript. Let's say I have two functions: Function 1: async function doSomething() { ...
user avatar
  • 1,183
1 vote
2 answers
121 views

How to create an API on Node.js that needs to be updated once a day?

I want to create an api based on Node.js and Express.js. This api should return an array of products on /products. To get these products on my node server, I need to call a third party api. However, I ...
user avatar
2 votes
0 answers
42 views

Software design for an Angular highlight&comment tool

We're building a new feature for an online editor that the user will not edit the document, but will be able to highlight & propose edits on the document. Very similar to google documents' ...
user avatar
  • 123
1 vote
2 answers
118 views

QR Code Scanning with location check

I would like to make an order-system with QR-Codes which is online. How I imagine it to work: A customer visits a restaurant. There is a QR-Code on his table which takes him to a public webpage where ...
user avatar
  • 19
1 vote
1 answer
66 views

Re-export (certain) library components from barrel file

Situation At the project I'm currently working on we're using Chakra UI to create our UI. But I guess this question applies to whatever (UI) library you're using. There are certain components that ...
user avatar
  • 111
3 votes
4 answers
2k views

How to store a password so that it can be passed to another site/service which is expecting a plaintext input

I am developing a website and I would like to allow users to use XMPP for live chat. I would like users to have the option use an existing XMPP account if they wish and store their XMPP username and ...
user avatar
-1 votes
1 answer
49 views

How can I pass a large amount of data from a JavaScript client to the web server in bulk

I have a Vue/Quasar application that allows the end user to convert an Excel Spreadsheet into an Array and load it into a DataGrid. The Spreadsheet has a list of peoples names, email address, ...
user avatar
0 votes
2 answers
55 views

Scheduled Task in webservice

The requirement is to trigger certain tasks (API calls) periodically for each user. But the frequency (time between triggers) is not fixed, the user can change it. In my existing solution I maintain a ...
user avatar
  • 101
1 vote
1 answer
409 views

Managing multiple state machines interacting with each others in ES5 Javascript

I have multiple state machines (7) managed by a "main" function. Because of system constraint this will be run on an old qtweb browser with ES5/IE11-like behaviour. So no promises etc. I'm ...
user avatar
0 votes
1 answer
97 views

Which one is good practice to do something like 'out' from C# in JavaScript? [closed]

Since I met the out keyword in C#, I'm trying to find an equivalent approach in JS. So, please take a look at the code and leave your opinions of existing cases or suggestions of new ways to implement ...
user avatar
0 votes
0 answers
28 views

How to validate against changes to "illegal paths" in backend requests for complex data structures?

We are building a backoffice web application where people are making changes to an array of nested objects. Because of totally non relevant business reasons there are things that users cannot change ...
user avatar
  • 519
1 vote
1 answer
190 views

Is usage of "global" types in typescript considered bad practice?

I'm fairly new to strongly typed languages, coming from the "jungle" world of JS and PHP. In my current Typescript project(React-Typescript), i'm struggling with a very fundamental question: ...
user avatar
  • 115
1 vote
2 answers
139 views

Is it better practice to create a div in the html or using javascript

I have javascript script that creates the same div everytime the user clicks enter and then set the event listener to the new input in the new div. example: //creates the container, text and input for ...
user avatar
1 vote
1 answer
52 views

What determines if a data type is an object or a primitive data type in JavaScript?

I have read that the null data type in JavaScript is a primitive data type, however due to a bug or something in the first version JavaScript, null is considered to be an object. However, let's assume ...
user avatar
  • 121
0 votes
1 answer
87 views

At the implementation level, how are JavaScript values represented in memory? [closed]

I want to know how variables are stored in JavaScript (what I mean is, how JavaScript stores the type and the value of the variable and stuff like that). But I was only able to find a tutorial about ...
user avatar
  • 109
0 votes
1 answer
126 views

Is a good practice using form tag's atributes in HTML?

Checkout this HTML using the attribute action, method and target from <form></form> tag: <form action="/action_page.php" method="get" target="_blank"> ...
user avatar
0 votes
1 answer
122 views

How to execute code "under the hood" in my no-code platform

As a learning project I started looking into how to mimic some basic features of a no-code platform. I usually code in Java/Python, have good knowledge over Javascript/HTML, but wanted to use this to ...
user avatar
  • 29
7 votes
2 answers
481 views

Why are sort() and reverse() JavaScript methods in-place?

Which are the technical reasons/considerations for the sort() and reverse() JavaScript array methods to be in-place operations instead of returning a new array without modifying the original one, like ...
user avatar
1 vote
1 answer
201 views

Advantages and disadvantages of including JS/CSS inside the HTML?

What are the advantages and disadvantages of including JS/CSS inside the HTML instead of separated files? Specifically concerned about performance issues, for example, if the CSS and JS are small and ...
user avatar
1 vote
2 answers
1k views

lambda function vs anonymous function vs callback function

I'm writing a introductory JavaScript tutorial series, I have a question about terminology. When explaining the Array.prototype methods, I've given an example of some code like: const letters = ['a', '...
user avatar
  • 2,412
-1 votes
2 answers
136 views

Using OOP objects mapping to DOM elements vs. querying the DOM repeatedly?

I'm trying to make better use of OOP, but I don't have good instincts for this yet and I sometimes worry I'm making things more complicated and/or less efficient. I'm wondering what is the best way to ...
user avatar
-2 votes
1 answer
37 views

Do I need a separate backend (Express) for an Angular project if using AWS for data storage?

So, I'm working on developing my first Angular project with/for a friend of mine and I have a design question before I really get started with things. I'm going to be storing persistent data on AWS ...
user avatar
0 votes
0 answers
35 views

How to best process unreliable conditional data on the frontend?

For the past couple of weeks, I was working on creating a simple visual display of some data as bullet points. I already have a solution for the title but I wanted to post this question, to hopefully ...
user avatar
0 votes
0 answers
73 views

MVP in plain JavaScript with nested components

I've been working on a system which has a number of MVP components implemented in plain JavaScript. They are instantiated from a main file and have no knowledge of each other which is great so far. ...
user avatar
  • 101
0 votes
2 answers
128 views

Dependency injection vs other design pattern

I really don't love the design pattern I've established here. It's kind of DI but not really, and the alternative is more constructor based DI, but I also hate it. Maybe it is because it is JS and ...
user avatar
0 votes
1 answer
780 views

Rabbitmq create queues dynamically based on number of users

I have a scenario where I have to route a list of messages that I get to respective users. For suppose if I have messages = [ { text: 'hi', user_id: 1 }, { text: 'hi', user_id: 2 }, { text: 'hi',...
user avatar
3 votes
3 answers
1k views

Should try-catch blocks be used when calling functions that already have them?

In JavaScript, if I have try catch blocks in a function that is meant to be called from another function, should I also put them in the calling function or just let the called functions handle them. ...
user avatar
  • 133
0 votes
1 answer
52 views

How are discriminated unions (e.g. in TS) used in messaging schemes?

In the documentation about discriminated unions in typescript, here it says: Discriminated unions are useful for more than just talking about circles and squares. They’re good for representing any ...
user avatar
  • 127
0 votes
1 answer
114 views

How encrypting website data works

If i wanted to encrypt a password on my website before its sent to the server, would i have to encrypt the password in javascript on the frontend for it to be hidden over the interent or could it be ...
user avatar

1
2 3 4 5
42