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
0 votes
1 answer
54 views

Difference between Resolvers and Controllers?

I may be overthinking it, but are controllers and resolvers the same thing in web applications? Coming from the MERN stack, everyone used to call these request processing functions "controllers,&...
user avatar
  • 119
0 votes
0 answers
9 views

Elegant way to go about navigating between components in React

I'm busy creating a navigation flow on the startup page in a SPA, and I'm experimenting with different methods of going about navigating between components. Here's an image to give you an idea of the ...
user avatar
1 vote
3 answers
205 views

Does it always take the same amount of time to retrieve the same thing from collection?

for example: const arr = [1,2,3,4]; const coordinate = [arr[0] + 2, arr[0] + 1]; here arr[0] is written out twice, when the code is executed would it literally go and find same value twice or would ...
user avatar
0 votes
0 answers
34 views

Design efficient real-time data subscription to reduce service workload

I am designing a service for a hobby app in JavaScript and looking for feedback on best way to design the service. TickerService Accepts an array of stock tickers. eg: ['AAPL', 'AMZN', ...] ...
user avatar
  • 1
1 vote
1 answer
184 views

Is it a bad habit to use other class' "private" variables in Javascript

I've gotten this idea in my head that i shouldn't use a libraries variable, if the variable name begins with '_', as it is standard to write private variables that way. But now i'm thinking i'm taking ...
user avatar
  • 143
0 votes
2 answers
76 views

Store static data in public folder as json file or directly in .js file?

I'm busy working on a website – somewhat new to this – and I don't quite know where I should store static data: in the public folder as a separate json file, or within the .js file as an object. In ...
user avatar
0 votes
1 answer
136 views

What can be done with closures that would be difficult or impossible to do without closures?

I am trying to understand what can be done with closures that would be difficult or impossible to do without closures. One use of closures I have found is to make an object's variables private, for ...
user avatar
  • 1,999
-1 votes
1 answer
88 views

How to measure the impact of a website speed optimization

Given: You have a list of opportunities* that may improve the speed metrics of your website. For example Total Blocking Time (TBT) is one metric that heavily impacts the experience of a visitor. You'...
user avatar
0 votes
0 answers
15 views

React function that opens and closes form in which user selects some data?

I am developing sales invoice form in ReactJS as SPA application, which communicates with API/DB (Laravel). I have the following use case: user clicks on one button (e.g. Select Person, Select Good); ...
user avatar
  • 1,009
0 votes
2 answers
486 views

Should I use unnecessary function for readability sake

I am implementing if/else statement, by using function "inCase" to make it more readable: const size = 'small' const equals = str1 => str2 => str2 === str1 const inCase = (obj) => ...
user avatar
0 votes
0 answers
64 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
84 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
24 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
6 votes
2 answers
542 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
  • 178
0 votes
1 answer
82 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
42 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
1 vote
2 answers
167 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
  • 171
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
86 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
3k 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
65 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
1 vote
2 answers
227 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
  • 161
0 votes
0 answers
40 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
47 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
244 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
  • 161
-1 votes
1 answer
219 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
  • 161
1 vote
1 answer
119 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
92 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
12k 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,181
1 vote
2 answers
131 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
  • 111
2 votes
0 answers
44 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
  • 133
1 vote
2 answers
140 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
82 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
50 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
67 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
638 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
99 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
32 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
254 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
182 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
53 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
94 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
133 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
125 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
500 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
214 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
2 votes
2 answers
2k 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,463
-1 votes
2 answers
152 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
38 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

1
2 3 4 5
42