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-cousin, ActionScript.

0
votes
1answer
2k views

element.style.setProperty(property, value) vs element.style.property = value [closed]

I was wondering if I should use element.style.setProperty(property, value) or element.style.property = value. I am very much tempted to start using element.style.setProperty(property, value). But in ...
6
votes
1answer
3k views

Why doesn't v8 compile typescript instead of javascript? [closed]

Since Typescript is just a superset of javascript (every javascript program is also a typescript program), I've got this idea - why doesn't v8 support typescript? or anything statically typed ...
-3
votes
0answers
43 views

How to represent JavaScript programs on paper? [on hold]

At work I'm developing a JavaScript library and often I have the need to represent on paper the classes that I'm building and their relationship in order to explain something to colleagues. What's ...
0
votes
0answers
15 views

How can I manage the state of my application using a dedicated object instead of what React offers?

Most of the react application I've seen are organized with components that, in my opinion, do too much. They may follow this pattern: class MyComponent extends Component { constructor() { ...
15
votes
5answers
7k views

Algorithm for flattening overlapping ranges

I am looking for a nice way of flattening (splitting) a list of potentially-overlapping numeric ranges. The problem is very similar to that of this question: Fastest way to split overlapping date ...
0
votes
0answers
49 views

How do I Make a Quiz Generator [closed]

I am new to HTML/CSS/JS/PHP/all that so please bear with me. I have been trying to figure out how all this stuff connects but never had an end goal so I didn't know what to ask. Now I can try to ask ...
10
votes
5answers
1k views

Is it beneficial to study past the basics of a core language when the primary goal is to rely on its framework? [closed]

Please keep in mind this is not another 'How much [insert programming language here] should I know before moving onto [insert framework here]?' What I'd like to know is how beneficial is it to learn ...
0
votes
1answer
49 views

Uploading file to the server for download

I've my front end written using HTML/CSS/Javascript. Front end is communicating with the backend(Oracle database) using Java Webservices (Spring boot app). Situation #1: User clicks on the Download ...
10
votes
3answers
484 views

What does it mean to inject data (vs behaviour) in a class constructor, and why is that considered bad practice?

I am reading the book "Learning TypeScript" by Remo Jansen. In one section the author describes how to create a very simple proof-of-concept MVC framework including how to create the Model class and ...
6
votes
2answers
297 views

A real-life example of using curry function? [closed]

I was struggled to find a real-life example of using curry function and get the benefit of using curry. When I google curry function I often see the example like let add = x => y => x + y; ...
1
vote
1answer
87 views

Methods to Securing APIKeys

I have read on several methods to securing an API key like gitignore or placing in another file if using an application, but at some point if taken the time, anyone can get the key, even when apikey ...
3
votes
1answer
689 views

What is a good method of storing test data for development and unit testing with angularjs and jasmine?

What is a good method of storing JSON data/objects for development and unit testing with angular and jasmine? I have seen some ways of accomplishing this. However, since I am new to unit testing with ...
0
votes
1answer
37 views

Split large Angular codebase to libraries

I am writing a potentially large web application using Angular 7, where I came across a design problem. My angular applications until now have been relatively small, so there was no problem keeping ...
0
votes
1answer
39 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. ...
0
votes
2answers
274 views

WebSockets vs Ajax call for scheduled event?

Intro I have been weighing the pros and cons of using WebSockets vs. an Ajax call for an event which will happen every x number of seconds (in this case 5). I'll start by explaining the scenario. ...
1
vote
1answer
1k views

Angular2: Service architecture + error handling

I need support for Angular2 service architectures. I am quite familiar with Angular2 but I don't see the best way to implement services, error handling and their connection with the components. I'm ...
0
votes
1answer
72 views

What does await do in JavaScript?

Sorry for this naive question. Reading some existing JavaScript I see a function with code like ... async function _load() { await ensureDir(path); return await readFile(filename); } ... why ...
66
votes
7answers
71k views

try-catch in javascript… isn't it a good practice?

There is a provision for try-catch block in javascript. While in java or any other language it is mandatory to have error handling, I don't see anybody using them in javascript for greater extent. Isn'...
-3
votes
1answer
36 views

How does event.target return the DOM object?

I read through documentation and searched on google, but couldn't find a specific answer. Currently, I have an object that subscribes to a click event. I am trying to understand how a view that ...
-1
votes
0answers
14 views

JS - Handle custom behaviours based on attribute value

I'm a developer that has the entire background based on languages with OO/FP approaches and now I'm working with NodeJS. For me, it's something new and, sometimes, kinda confusing. Right now, I need ...
2
votes
3answers
398 views

Performance increase by only attach onblur handler inside of onfocus handler?

Given a web page with input fields, does it have a performance difference whether or not you assign the onblur handler inside of the onfocus handler like so: var inputFields = document....
1
vote
2answers
495 views

ModelState Validation vs JQuery vs Remote

I was stuck with some validations for quite a while. I have been thoroughly searching the internet to find ways to apply the validations I require. I came across many methods for validations even ...
11
votes
3answers
520 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 ...
18
votes
3answers
46k views

Why does Javascript use JSON.stringify instead of JSON.serialize?

I'm just wondering about "stringify" vs "serialize". To me they're the same thing (though I could be wrong), but in my past experience (mostly with asp.net) I use Serialize() and never use Stringify()....
1
vote
1answer
1k views

Efficient development process for Golang (or any backend) and JavaScript?

I am developing a web application. The frontend is a mix between JavaScript and server-side generated html. The backend is written in Golang. Might not be very important, but if somebody made a ...
0
votes
1answer
98 views

What would be more efficient, move DOM elements or clone them?

I have this dilemma, I have to make a menu, the basic estructure is four to six main menu items and each one can have N level 2 menus and each sub menu can also have subs. I get from the server this ...
1
vote
1answer
306 views

Angular template variable reference

Here is a weird problem in Angular: <input #pin1 type="password"> <p>You entered: {{pin1.value}}</p> If you type something in <input>, the <p>'s content will not change ...
0
votes
1answer
123 views

Algo : Compare strings to find likely

I am trying to find best way to compare or find similarity between strings. Much similar to search functionality , for example when we ask new question in Programmers we are shown a list of old ...
6
votes
3answers
654 views

“Comment everything the right way” and “Instead of writing comments, write more readable code.” - Both valid strategies?

When trying to learn about proper comment practices, I found a lot of conflicting opinions, and it's obviously a very subjective topic. So I'm not going to ask "Should I comment, or should I not?" ...
0
votes
2answers
68 views

Should / When to create javascript object to serialize data?

I'm working on a React/Redux application. I receive a data object from the api resembling this: const dataObj = [ { id: 1, name: "Filo", activity: 9, info: { statusCode: 4 ...
1
vote
3answers
238 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 ...
1
vote
1answer
38 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
1answer
167 views

Organizing reducers in Redux

I will use the following popular todo list example for demonstration. Let's say I wanted to create a very basic todo list with this structure as the app state: { todos: { todoKey1: { ...
1
vote
1answer
280 views

Would onpushstate be an anti-pattern?

In Single Page Applications, it's common to update the URL when navigating, and re-render based on the new URL. This can happen when the user hits the back and forward button, clicks on an anchor tag, ...
3
votes
2answers
590 views

How to write good javascript unit test descriptions

I come from a python background. I typically write long unit test descriptions that link the test to a user story. The test is as much about justifying why the code exists and how it fits into the ...
6
votes
1answer
2k views

React: Nested object as state vs individual properties

Are there any use-cases where a nested object as state is either more optimal/easier to work with than individual properties? For instance if I wanted to express some user controls for interacting ...
3
votes
1answer
157 views

Dealing with conditional verification logic using guard assertion

I have parametrized test with 2 variants: NULL value and any NOT NULL value From this value is depends one assert: In case NULL it should be checked if object has field1 with value1 In case ...
0
votes
1answer
53 views

Load files depending on browser or write workarounds within the file?

I'm writing up this website running under IIS with .NET Core. I developed most of the site with minimal use of JS so that the server will be doing most of the work (and thankfully so because of the ...
7
votes
1answer
634 views

Order and filter Server-Sent-Events in angular.js eventsource

I have a Client in AngularJS where I consume multiple SSE (Server-Sent-Events) in Java from the Server Side (there are multiple endpoints in different web servers in the backend). Diagram link I ...
2
votes
1answer
684 views

Collecting user input to use as query with API

I'm attempting to collect the user's input and execute a search using an API. At this point, I can use the API (ebay search) by typing keywords into the html document- but I want the user to be able ...
0
votes
2answers
88 views

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. ...
3
votes
2answers
1k views

Linking service and factory functions to controller $scopes in AngularJS

I'm trying to keep my controllers as thin as possible, so I keep my domain logic in services and factories. When I need to call a function in response to a user action like a click I assign the ...
-1
votes
3answers
99 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
votes
1answer
80 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 ...
3
votes
2answers
1k views

Terminology - Cache (Javascript)

I have watched a couple videos on JavaScript where the presenter mentioned "caching" a variable but I didn't see them do anything in the code that would "cache" it beyond normal assignments. When I ...
7
votes
4answers
873 views

in dynamic language like javascript how do you know what the argument is?

In Java or Scala if I have an argument configuration: Conf, I can look for Conf class/trait/case class and see its construct so I know which arguments to pass. Recently I started dealing with ...
0
votes
1answer
125 views

Using custom mime type for drag'n'drop events or data attribute dilema

I am having a dilema on a html/js application I have been requestyed to handle drag'n'drop events in order to display a dropped image in a div if is not from images that are already displayed in my ...
3
votes
4answers
365 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 ...
0
votes
1answer
129 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
38 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 ...