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.

1
vote
0answers
40 views

Exporting functions usable by both client-side and server-side

So this isn't a question on how to do it, but more of a clarification on how it works. I'm using Vue and I'm creating a file that's usable by on both the client side and the server side (logic should ...
-1
votes
1answer
197 views

How to extract SSML parsing code of espeak to implement SSML parsing at SpeechSynthesisUtterance?

eSpeak implements SSML parsing. SpeechSynthesisUtterance, at least as implemented at *nix, does not parse SSML input at Chromium or Firefox browsers. How to identify and extract the relevant portions ...
0
votes
1answer
65 views

What types of operations should go into Node.js as opposed to client side javascript functions

I am building a web app with a lot of different API calls: our own proprietary REST API, third-party library API calls, etc. All of these calls either retrieve data, update data, delete data, or ...
1
vote
3answers
462 views

How to handle parallel requests, different response time and atomicity of transactions

I have a table of data and I can create , update and delete rows. I have apis to do these operations. The following steps happen I create a row and send a create request to server. I update some ...
1
vote
1answer
81 views

What is the best way to store message threads?

I'm integrating a messaging feature into an application written in Javascript and would like to know which is the preferred data structure of storing messages. The two structures I can think of so ...
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 ...
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 ...
0
votes
1answer
574 views

Difference between JavaScript self-executing function and constructor function in private methods

I know this has been asked many times before, but I still don't quite understand what the difference is between the following: var Foo = function (){ //1 this.a = ""; this.b = ""; var ...
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
551 views

Webpack and Lazy Load for large-scale Web Application

Background I am trying to develop with Webpack and JavaScript. Webpack would bundle all source code into one single file. When application becomes large, the file would be very large and cause ...
2
votes
3answers
159 views

Should I be lenient with types when accepting JSON data? (String vs number)

Background: So while Javascript implicitly convert various data types and hence may seem almost type-less(is there such a thing?) it does have different types. Most of my colleagues seem to think ...
1
vote
1answer
135 views

How should I structure my Observables on a Nodejs application with RxJS

So I am learning reactive programming, and I am building an app for fun that listens on various stock information tickers, and calculates specific things to show in charts etc. So right now I have ...
1
vote
1answer
113 views

Rest api manager encapsulation required or not

I am currently designing a software in which I have to use a rest client. I have decided to use a particular library, but am stuck whether I should use it directly or add a custom encapsulation layer. ...
1
vote
1answer
762 views

PHP Post vs JavaScript Ajax Request

I have been into web development with both client amd server side code, and have been using JavaScript Ajaxto receive and manipulate for data along with PHP scripts. However, I noticed that ...
3
votes
2answers
458 views

REST Api Design Patterns

I'm developing a REST Api using Node.js & Express.js. Recently I've started looking towards best practices for REST Api design but it's bit confusing so please bear with me. For Example: Lets ...
0
votes
1answer
76 views

WebApp Design: Better way of updating information in a DOM element

Background: I was working on a personal project to create an Task Checklist Web App. I worked on the code with vanilla golang and javascript. It is a very simple app with limited capability. I've used ...
0
votes
1answer
670 views

Better alternative to having a html form with select input on every row in table

I have a web application (laravel) with a page which presents a large number of rows (financial transactions) in a HTML table. On each row I want to have a drop-down (select input) allowing the user ...
0
votes
2answers
139 views

Is it acceptable to break MVC by storing data in the DOM in order to reduce load on the Database Server, ever?

I am currently using NodeJS & Express to load webpages which contain element content that is rendered via a query to MongoDB. A GET request will create Button elements, binding the MongoDB _id ...
14
votes
1answer
579 views

Does the “function returning function” pattern have a name in JavaScript?

I use this pattern quite often in JavaScript. Here is an example: const comments = [ { text: 'Hello', id: 1 }, { text: 'World', id: 4 }, ]; const byId = id => element => element.id === id; ...
0
votes
0answers
56 views

When does DRY become counter-productive? [duplicate]

I'm working on a project using Reactjs on the front-end and while working on it, I have been focusing on 'thinking in React'. In doing so, I'm building re-usable components and trying to not repeat ...
5
votes
2answers
235 views

Better to send all data to client or query server for every search?

I have a search function on my site that needs to search through ~2000 items (this table never changes, it will always have the same number of items) stored in MySQL. All it needs to do is search by ...
-1
votes
1answer
379 views

coding practices: return vs else [closed]

Which coding style is considered better practice? if-return: function fn { if (condition) { /* if true: insert code here */ return; } /* ...
0
votes
2answers
2k views

Why is it uncommon (is it?) to use _ (underscore) in JS private vars?

Coming to JavaScript from C# and C/C++ world, I'm used to decorating my private members with underscore. But a couple of JS devs I know have told me it's not common in JS world, and my code looks "...
0
votes
2answers
247 views

Is it still relevant to keep script tags in the footer?

Working at a company that loads all javascript at the end of the page load. This means I can't do $(document).ready() on my page, because jquery isn't loaded (the scripts are injected into the footer ...
1
vote
2answers
72 views

JavaScript constraints on object's values

I'm currectly reading the book JavaScript: The Good Parts by Douglas Crockford. The opening of the Chapter 3 Objects immediately confuses me with a (possible) contradiction. I re-read the two ...
-3
votes
1answer
140 views

Do I need a dedicated “LICENSE” file when license is specified elsewhere

npm packages have a standard way to define which license an uploaded package is licensed under. In the package.json there is a field called license which should contain a SPDX license id. Is there ...
0
votes
1answer
133 views

In the react docs why is binding of *this* preferred over arrow functions for event handlers?

In the React docs, the constructor functions of class components contain lines where this is explicitly bound for event handlers e.g. in the docs for handling events class Toggle extends React....
1
vote
2answers
200 views

Do I need to put a license in my website's HTML and/or CSS?

I am making a website for a competition my school is taking part in, however I am not on the team and am not receiving any compensation (save for better references :P). The only condition I have set ...
1
vote
4answers
236 views

When is it justified to write implicit conditions? [duplicate]

As a rookie programmer, I've only recently been digging into benchmarking, and have been comparing various ways of accomplishing the same task in terms of speed. Most of the time, the result is ...
0
votes
1answer
156 views

Modeling JSON with Javascript

Using C# I've modeled a JSON message this way: public class MessageBase<T> { public MessageBase() { this.message = new List<T>(); } public string type { get; set; } public ...
3
votes
0answers
203 views

Redux Saga pattern for large, non-specific server responses

Our current Redux state tree is this: { "dog": { "name": "Barkley", "age": 6, "hungry": false, "location": "Living Room", "height": "36 in." }, "...
0
votes
1answer
64 views

What does the details of instantiation encapsulation mean in factory design pattern?

I am trying to understand the factory design pattern and how it can be implemented in Javascript. So far what I understood is factory design pattern helps to create an instance of more specific class ...
-1
votes
1answer
416 views

Hosting a static website containing JavaScript/jQuery

I have customized a free downloaded web template as my simple, static website. It contains HTML, CSS, and JavaScript/jQuery. I want to make it live, and am confused from where to host it. The hosting ...
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 ...
0
votes
1answer
58 views

Thinking about a setup to work with react and front end development

On my team I'm working as a frontend developer in a React codebase. We're building an application and do everything in React. Before this I was actually always a backend developer. Now I have the ...
-1
votes
1answer
94 views

Design ideas for showing another website's page in my own website

I would like to show a web page from another website and show it on my website. I want to annotate some text on their website content. Conceptually I know what needs to be done: - I will capture their ...
2
votes
1answer
53 views

Where should I do integration tests in a multi package project

Background: I am working on a node project which consists of a core package and several addon packages. For the end product to work, the core package and atleast one of the addon packages should be ...
0
votes
2answers
597 views

Is there an advantage to using AJAX rather than a simple window.location?

When doing simple server updates or submitting forms or that type of thing, I have come to a fork in the road...using AJAX: var ajax = new XMLHttpRequest(); ajax.open("post", "myserver.php", true); ...
-2
votes
1answer
420 views

Choosing the right architecture for my web application

I've started working on my web application and I'm stuck at the design stage. I cannot decide which web technologies would be the most suited to this project. Let me explain what I want to achieve: 1)...
0
votes
1answer
158 views

Using CSS classes to express state

Is it good practice to express the state of an HTML element--such as whether an input's value is valid--using a CSS class? Would it be better practice to use data attributes, the properties of a ...
1
vote
0answers
877 views

What are the best practices for picking selectors for web scrappers?

The following is an example using https://github.com/GoogleChrome/puppeteer 'use strict'; const puppeteer = require('puppeteer'); (async() => { // const browser = await puppeteer.launch(); // ...
4
votes
1answer
170 views

Proper way of throwing errors in a JavaScript library?

Let's say I am writing a simple library in JavaScript, with only a few functions: Calculate the factorial of a positive natural number Find the least common multiple from an array of integers And so ...
-3
votes
2answers
464 views

Are Java and JavaScript converging? [closed]

It seems to me that Java was the computing language that could be used anywhere and JavaScript was the scripting language for the web and things stayed that way for a long while. There are countless ...
0
votes
3answers
415 views

Code pattern to have the least possible code complexity (Javascript)

I've been looking for the ideal coding patterns used to score well in a Cyclomatic Complexity. Of course, code will be subject to change according to what is being developed but regardless the ...
-1
votes
2answers
572 views

Consuming Web API in website with role based views

I understand Web API. I understand websites, how they call a web API and all the good stuff. My question is, how do you control the user view in the website consuming the API, based on the API ...
0
votes
1answer
166 views

Develop for MySQL and SQLite3 Concurrently

I am developing a javascript (Node.js) desktop program that works with an existing MySQL database. I would like to (eventually) distribute to others with based on SQLite, or MySQL if they need (or ...
2
votes
1answer
288 views

Pros and cons of different ways to create objects in Javascript [closed]

Context I am writing a JavaScript library, and I am finding that I don't know what the best way to support object creation. I came up with a list things that I am considering: var obj = Library....
-3
votes
1answer
56 views

Adding links to posts using RegEx - should it be server side or client side?

I am working on adding a feature to a forum where I look for keywords in posts and add links to these keywords. For example, say a user's post includes the phrase "HP Printers". This phrase would be ...
0
votes
1answer
77 views

What to test in this module?

Aside from the probable dozens of bugs you can spot in the code below, I'd really like to know what would most people would consider testing in the code below. I have 8 similar exported functions, so ...
2
votes
1answer
160 views

Describing JS program flow in @fileoverview

I have to edit other people's JavaScript code. The code usually loads some data from a Web API, generates a table, places it into the HTML page, and attaches some event handlers. Due to the async ...