Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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-...

-1
votes
1answer
72 views

Would I need a web framework if the app is running locally and not in the net?

I need to make an Employee Payroll application and the client specifically stated that the application will run on their computer locally and will not be hosted anywhere in the internet. I can code ...
0
votes
2answers
54 views
+100

When using Redux/Redux-Saga - should JWTs be set in the action creators/sagas?

Almost every blog post I've encountered around generic auth handling using JWTs in a React/Redux/Saga application does the same thing, which is to store the JWT in local storage, in the action/saga. ...
-4
votes
1answer
29 views

Returning a value from an if statement into global scope [closed]

let CalcGrade = function(studentScore, highestScore){ let gradePercent = (studentScore/highestScore) * 100; let gradeLetter; if (gradePercent == 90 <= 100){ gradeLetter = 'A'; } else if ...
-1
votes
0answers
34 views

How many request we can make at a time using “request” middle ware in nodeJS application

I am running a cron job every 5 mins to get data from 3rd party API, It can be N number of request at a time from NodeJS application. Below are the details and code samples: 1> Running cron Job every ...
1
vote
2answers
154 views

What algorithm is used in subtitles?

What algorithm does a video player use to find the subtitles to show at any given time? I'm building a video player that displays some notes on different times over a video. Each note has a starting ...
-3
votes
0answers
70 views

Is putting related functions into a stateful class just for testability purposes a code smell?

Take the following JavaScript module as an example of a utility class helper file that exposes many related utility functions. This module initializes the state of module and the exported functions ...
-2
votes
0answers
34 views

What Is A Redux-Glorified-Setter?

I see this phrase as an alternative name for badly designed action creators because they have a lot of dispatching. On the other hand, isn't it the purpose of action creators? to centralize ...
0
votes
0answers
16 views

controlling multiple components in web application

In my small web application (about 3k lines) my UI is composed of lots of buttons, toolbars, selection boxes, tables etc. Where each action affects the state of multiple UI elements. Do you ...
0
votes
1answer
81 views

Why are React keys limited to strings?

In React, when rendering a mapping from elements of a list/array/iterable to React elements, we're required to attach a locally-unique key to each element. Generally this is so that if an element ...
2
votes
1answer
35 views

continuous deployment of web application built with multiple packages

Our react web application is broken down to multiple components. Some of these components are part of the same git mono repo and some live in a different repo. Now, to implement a bug fix we have to ...
3
votes
1answer
121 views

Best practice for REST result payload when field may have single or multiple values

I Have a REST API endpoint where the caller can supply some optional filters for the results. GET api/inventory For example, an object member of a GET request may look like the following { "...
-1
votes
1answer
98 views

What options are for a GUI for a Java application? [closed]

This might be a bit of a wide question. I have a couple of classes in Java that take input a String which is a mathematical expression and evaluates it. I want to implement a desktop GUI for this. ...
2
votes
1answer
69 views

How should I define hardcoded strings with some variable parts? Reuse more characters? Or keep the whole sentence?

for example, sometimes I need to define a hardcoded string with some variable parts, I often have trouble to choose the style: style 1 : reuse every characters when possible showMessage(num){ let ...
0
votes
1answer
29 views

Cross-domain data binding

I've been developing several front-end web-applications recently that bind against a database using a RESTful CRUD api. I've noticed a massive amount of boilerplate code going into defining the API. ...
-1
votes
2answers
78 views

How to process a login form data?

I have created a login form for my website, but the issue is how to process the data provided in the form by the uses. You see, I can't just write a basic function like this one - myfunction(){ if(...
10
votes
2answers
398 views

How can I prevent a user from editing my code in their browser?

Description I'm designing a Node.JS application (more like a full website). The app will send five JavaScript files and will have <script> tags linking them together. Question How can I ...
0
votes
0answers
37 views

Event loop task and micro tasks order execution

I m actually studying different part of the event loop in javascript and I'm stuck understanding the execution order of the tasks from the task queue and the different microtasks. For now, running ...
0
votes
0answers
16 views

Data sharing between web app components

If I have several interactive components (grids, tables, graphs, dropdowns, autocomplete inputs, etc.) that display processed data from the same "global database" (everything resides on the client ...
-1
votes
3answers
90 views

Writing elegant promises in Node.js

I am having a real difficult time writing some clean code with a simple user registration/login manager. I am trying to stay out of nesting/callback hell, and am also not seeing any benefit in using ...
1
vote
1answer
32 views

Dynamic execution of Template Literals using a Map

I have a system that is generating internal events for objects. I am extending their debugger to display a human-readable version of the events sent to the debugger. For instance, the system will ...
0
votes
0answers
16 views

Promise, Ecmascript and Whatwg event loop

I've recently learned that setTimeout is not part of Ecma 262 standard but takes part of WhatWG one. I have one misunderstanding concerning these two standards and I can't get how they converge. For ...
0
votes
1answer
41 views

Can websites written in JavaScript make requests to SOAP API's?

I have an API written in SOAP 1.2 that I am trying to give to a developer whose website is written in Javascript and said they can not request the file because they do not know PHP. From my ...
1
vote
1answer
131 views

Strategy to deal with huge data

I have a Spring based java webservice which is returning JSON response. The problem is that the JSON response takes long time because the SQL involved is querying huge chunk of data and it takes 4-5 ...
-1
votes
1answer
52 views

Difference in use-cases for just using '.catch' v.s using 'Throw Error…' with '.catch'

If .catch catches any errors upon request attempt, why would I need to use Throw Error... with .catch? For instance, what is the throw Error used for, that the .catch doesn't handle automatically? ...
0
votes
2answers
97 views

Check or not objects in a Javascript API?

I'm writing an API in JavaScript, and I'm confused whether or not I should check if the API user is passing me the correct type on which the API expects to work. Actually not the type, but if you are ...
2
votes
2answers
338 views

Should I use Array or Set if both can be used to finish my task?

for example, Suppose I have a 2d array: let filterArr=[ [1,1,0,1,1], [0,1,1,1,0], [1,1,0,1,0] ]; I want to find and store the index of column that all are 1, i.e.:position 1 and 3, and the ...
0
votes
1answer
46 views

ReactJS - proper way to handle a responsive design approach?

I've always used CSS and media queries when it comes to responsive design. I've been developing in ReactJS for a while, but I feel my approach to responsive design is sloppy. I find myself using a mix ...
2
votes
1answer
99 views

Resolving request congestion at browser by using socket as “fast lane”, any consequence?

I have received multiple reports from users of a Web-based GIS application we have rolled out one to two year ago, complaining the application becomes unstable/unresponsive. After a brief ...
-3
votes
4answers
249 views

Might there be two types of a “callback” in programming? [closed]

I know two definitions for a "Callback": A function that is being called-after ("called-back when") a certain event is triggered. A function that is passed to another function as a parameter. An ...
1
vote
3answers
169 views

In Haskell, is it a “violation” of functional programming to interact with something that was not a function parameter?

I'm sure this must have been asked before, but I can't find anywhere that actually answers my question, so apologies if I have simply overlooked this. I am currently learning Haskell, and loving the ...
0
votes
0answers
41 views

Naming convention for string constants and string functions

I'm creating a react application, and I want to keep all my string constants in a single file like: export const STR_LOGIN = "Log in"; //h1 on a login page export const STR_USERNAME = "Username"; // ...
3
votes
1answer
155 views

What's the best way to handle a large multi-file class in Javascript?

I have a very large class of 59 methods and about 3000 lines of code. I know that's far larger than most people would want, but the class represents a virtual machine, and most of the methods are run ...
0
votes
0answers
22 views

npm subfolders and git submodule

So I'm wondering how I should go about this. I have a frontend and a backend that's currently meshed together as one git repository. I would now like to separate them into a front end repository and ...
-3
votes
2answers
177 views

Is this an anti pattern in Javascript?

A common pattern I've been using for JS/NodeJS applications is the following: import { utility1, utility2 } function exampleScript() { utility1() utility2() // Does something } Basically my main ...
4
votes
0answers
107 views

Should an SPA use OIDC's Implicit flow or Auth Code flow?

We are developing a new Angular SPA which leverages Keycloak for its SSO abilities using OpenID Connect (OIDC). The app is currently designed to use the Implicit flow to retrieve short-lived access ...
0
votes
1answer
134 views

Is JavaScript unique in the way it treats missing property access?

Javascript has the behavior where an error is not thrown on missing property access on objects, which is the cause of many pernicious bugs: console.log("iPhone".missingProperty) // undefined I'm ...
0
votes
1answer
148 views

What is it that is so hard about ES6 modules for Node? [closed]

It seems like ES6 imports for Node have been a bugbear for a while. There is the --experimental-modules flag, or options like using Babel - but AFAIK ES6 modules still aren't supported in vanilla Node....
1
vote
2answers
124 views

Is it conventional to use both await and .then()?

I've written a bit of code that looks like this: async function fetchData() { const json = await fetch(ENDPOINT + key.key).then(data => data.json()); //Do something with the data } It's ...
0
votes
0answers
152 views

How do functional programming advocates use a framework like React or Angular?

I read this blog post recently: The Two Pillars of JavaScript Part 1: How to Escape the 7th Circle of Hell, which is essentially a criticism of object oriented programming, and advocacy for funtional ...
1
vote
3answers
168 views

How does JS Promises works being single threaded

Javascript is single threaded. What I understand from this is if JS i executing on line of code lets say a function. It cannot go to the next line unless that function has been removed from the stack. ...
2
votes
2answers
99 views

An options parameter vs chained functions for object initialization?

What concrete objective advantages do chained functions have vs an options parameter for object initialization? What do I mean? Well as one example there's a library called dat.GUI that uses the ...
2
votes
0answers
64 views

Is there a recommended design/architecture when developing a JavaScript module?

Practicing some of the ES7 features, I started developing a class to perform some actions on the DOM and use the new features. I used Babel to make it work on the browser, and the code looks something ...
3
votes
4answers
344 views

How to do BDD for CRUD?

I want to understand how Behavior-Driven Development (BDD) can be applied to building CRUD applications. I have read a lot on the subject but I just don't get how I'm supposed to apply it. I learn ...
1
vote
1answer
83 views

Should this part of my web-app implemented on server-side or client-side?

I want to write an application which monitors a few URLs (like a couple hundred) of all branches of school. By monitoring, we mean that it sends requests to those URLs at regular intervals (Interval ...
0
votes
0answers
59 views

Is giving sub reducers access to the full state a bad idea?

I've got a Redux app with a fairly flat state tree. All sub reducers handle one separate part of the state, and they are tied together with combineReducers. My problem is that in a few cases I need ...
3
votes
2answers
116 views

How can I avoid using global variables in simple Javascript SPA?

To learn Javascript I am building a simple Single-Page Application. It is a basic slideshow app that needs only to process some basic settings and execute some behaviors. The basic structure of my ...
0
votes
0answers
45 views

JS ecosystem - In which oder I should learn them?

I'm migrating from Java to JS and I would like to know what is the best way to do it in the field of JS ecosystem. After reading all the You Don't Know JS series by Kyle Simpson, I would like to ...
0
votes
0answers
143 views

Codeigniter Notification System URL Structure

First I apologize for my english. I am trying to develop a facebook-like notification system with Codeigniter. I know it's much better technology, but it's not about using them right now. The ...
1
vote
1answer
77 views

Simulating Comparison Without Using Comparison Primitives

In the same way that you can simulate the if statement and functions, I am wondering if there is a way to simulate the comparison operators ==, !=, >, >=, <, <=. For example, in ...
1
vote
1answer
68 views

OrderedMap or List for Redux structure?

I'm implementing a Redux store for a React app using redux-saga for API calls. I've used Immutable.js before for other Redux-using React apps but the nature of previous projects always evidently ...