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
26
votes
6answers
4k 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() { ...
1
vote
2answers
108 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 ...
2
votes
0answers
38 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' ...
1
vote
2answers
97 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 ...
1
vote
1answer
24 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 ...
3
votes
4answers
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 ...
-1
votes
1answer
44 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, ...
0
votes
2answers
42 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 ...
1
vote
1answer
79 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 ...
0
votes
1answer
94 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 ...
0
votes
0answers
27 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 ...
1
vote
1answer
107 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: ...
1
vote
2answers
116 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 ...
1
vote
1answer
50 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 ...
0
votes
1answer
80 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 ...
0
votes
1answer
117 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"> ...
0
votes
1answer
116 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 ...
7
votes
2answers
457 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 ...
1
vote
1answer
192 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 ...
1
vote
2answers
471 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', '...
-1
votes
1answer
78 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 ...
-2
votes
1answer
29 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 ...
0
votes
0answers
32 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 ...
0
votes
0answers
52 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. ...
0
votes
2answers
120 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 ...
0
votes
1answer
403 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',...
3
votes
3answers
535 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. ...
0
votes
1answer
47 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 ...
0
votes
1answer
110 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 ...
2
votes
1answer
309 views

When should a variable be declared / Value assigned?

So we have quiet a big TypeScript codebase at work, where each method resides in its own file. Now in a lot of those methods the variables are often declared all together at the top/beginnng of the ...
5
votes
3answers
383 views

Qualms over the 'flexibility' advantage of using dependency injection

I'm currently studying dependency injection and I'm having some issues with the so called 'flexibility' advantage of using dependency injection. The flexibility advantage is mentioned in post ...
-2
votes
1answer
96 views

How to warn devs after installing or updating npm packages? [closed]

I want to warn devs in my team to rebuild the docker containers after installing or updating npm packages. This is because whenever we edit packages in the environment the only way we've found to test ...
0
votes
0answers
39 views

Mediator design with a circulator dependency

My project is web related, and the intent is that I am decoupling two pages worth of actions so that each class would have a list of actions on their page, and if any action so happens to navigate to ...
0
votes
1answer
77 views

What is the use case of BroadcastChannel API?

I'm reading about BroadcastChannel API https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel . It seems that it is already on market for a long time, and quite cool as well. However, what ...
1
vote
4answers
438 views

Do all dynamically typed languages not support function overloading?

I have noticed that JavaScript and PHP and Python do not support function overloading. Do all dynamically typed languages not support function overloading? If the answer is yes, then why is that?
0
votes
2answers
344 views

Defining default values for Boolean arguments in JavaScript

Is it usually recommended to define default values for Boolean arguments? I mean, is it usually recommended to define a function like this someFunction(a, b, x) { // a and b are strings, x is true ...
1
vote
2answers
86 views

Using objects to construct nearly the same objects

I am getting worried I have some terrible design pattern here in JS/Node.js/MongoDB. It seems to that to create an object, I need an object that looks like that object. This includes data that comes ...
1
vote
2answers
321 views

JS - two array filters vs. one forEach?

I've had a question for a while. I know that the Array prototype method filter is generally preferred over forEach, and I believe it is typically faster at the job as well. But what about if I have ...
0
votes
2answers
53 views

Strategy for Chrome timing out on a Database cleanup job which takes a long time

I have a notifications app which sends users notifications. It uses a .NET core backend, an angular frontend and Cosmos DB. Within this I have an API endpoint function which is linked to a button used ...
-3
votes
1answer
116 views

Why isn't JavaScript always async? [duplicate]

In JS, code runs single-threaded, that's why asynchronicity is necessary. I cannot use code like result = someRequest(), instead I need to give it a callback someRequest(resultCallback) or write a ...
0
votes
0answers
20 views

Designing a Js lib, dependencies and peerDependencies

I create a new lib that I want to use in all of my projects. It will contain wrappers on famous libraries such as VueJS and Axios. How should I reference these libraries, from the specs I see that I ...
2
votes
4answers
275 views

What would be a good analogy for explaining higher order functions?

I am teaching a beginners course on JavaScript programming and web development. Passing a function as a value into another function is a very common thing in JS from the very beginning. As the ...
0
votes
0answers
27 views

Adding API wrapper to Vue project - any advices or recommendations?

I'm starting a new project that consists of backend (REST Framework - Django) and frontend (Vue app). First I'm trying to figure out the "best" way to handle API requests. For example - not ...
-1
votes
1answer
82 views

Allowing end users to upload a large amount of data using Excel

I've read Allow users upload CSV files, and embed the data for a simple API , Importing large data sets into a database over the web the closest concept is Is there a way to efficiently allow a user ...
-2
votes
1answer
125 views

Can I manage a NoSQL database with only JavaScript?

I am creating an app with Deno (a personal project), and I manage the "database" with only the Javascript code of the Deno enviroment, modifying JSON files like any other JS object. For me, ...
0
votes
0answers
38 views

Encrypting login details locally and securely while using Electron and JavaScript

I'm trying to figure the best solution for encrypting a user's login details locally and securely while using Electron. Ideally I'd like to secure them on the client computer vs using something like ...
3
votes
1answer
101 views

What is the role of ISO in the ECMAScript standardization process?

I've been told on StackOverflow this questions was off-topic so I'm asking here: From this webpage (ISO/IEC 22275:2018): This International Standard defines the ECMAScript Specification Suite ...
-2
votes
1answer
83 views

Modify method behaviour at runtime

I have a scenario where user has multiple filters in a web application and a displayed list of items. In the gui it has multiple FilterGUI that he/she can tune interacting in the browser (these are ...
0
votes
0answers
30 views

Design to store user information in session storage in react

Wanted to ask if the following design is okay based on my requirements: Brief Description of my requirements: I have a requirement to gather some info from the user and then the user attaches a file ...
0
votes
1answer
151 views

Web Components/Redux with .NET Core MVC viable?

I'm currenty building several new themes using NopCommerce, a .NET e-commerce platform using the MVC architecture. NopCommerce exposes a lot of services to you for communicating with the db, and is ...

1
2 3 4 5
42