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.

3
votes
2answers
231 views

I keep bouncing from “god function” to “tiny SRP functions” how do I break this cycle?

This question is important for me in growing in my technical abilities. I find I swing from end-to-end, like a pendulum, in writing code that is simultaneously DRY yet readable & efficient. And I'...
1
vote
1answer
538 views

Unit testing rabbitmq messaging library?

I'm having trouble figuring how I would test a library that intended to be used for communicating with another web service. For example, I have a Messenger class that initializes a connection and ...
0
votes
0answers
744 views

Choosing the right design pattern for a SPA web application

I am currently struggling choosing the best design pattern for a single page web application. Say that it is a contact application and there are several dependent parts, each part changes when the ...
2
votes
3answers
3k views

Time zone conversions on back-end or front-end

I have a web app with an ASP.NET API back-end and React front-end. It also has a mobile app built in React Native. Question is about date/time values. I have two options in handling time zone ...
1
vote
1answer
203 views

how to create API's from mere programming language

all programming languages have api's to interact various systems as a example javascript languge has Dom api to interact with the web page. C language languge has file access api to interact with ...
1
vote
1answer
58 views

Do events/functions need to be redefined at each level for an API?

I typically write code that only I use, but I do have a public github with some JS libraries. A key component of most libraries are events. My question may be opinionated, but I don't know where else ...
1
vote
3answers
567 views

Looking for a way to handle Javascript file dependencies

I'm making the transformation from being a web developer whose pages often contain loads of <script> tags to one whose pages contain modular Javascript, encapsulated in functions, etc. I'm ...
0
votes
1answer
53 views

Binding an interface on top of third-party modules to develop future-proofed and scalable apps

Every day a couple of new javascript modules are created and published around the world and we need to think long term. Let's say today I need to use an ORM module to go smooth and fast. But tomorrow ...
0
votes
1answer
35 views

Real time update as user entering information like what Google doc do or use a save button

I am making a design decision to real time hit API to save all the fields in a form when user make an change even if hes not finished yet. Or, use a save button like most app does. Any pros and cons ...
3
votes
2answers
551 views

What is the right time to go for Code Refactoring, not optimization?

I've been working on a Python(Django)/JavaScript(AngularJS) based application for some time now.(I learnt all of these on the way, had previously been a Java only programmer)and have hit moments where ...
0
votes
1answer
77 views

architecture - relation of scraper and orm classes

Consider the following application structure. The scraper class extracts the necessary information from a page, and I want to save it to the DB. The ORM class is a wrapper around sequelize.js. It ...
1
vote
2answers
195 views

Declaring a function without named parameters that accepts at least 1 argument

Say I have a function whose first parameter is used differently depending on how many arguments are passed. In this case, it is easier to just process the arguments object as a whole within the ...
1
vote
1answer
78 views

Styling shareable React component?

I've been looking for a good way to style a react component just using css stylesheets. I would have used style-loader, because it's as easy as require('./style.css') and allows to save the final ...
1
vote
1answer
437 views

HTML and iframe organization for dashboards [closed]

I need to build a small website for my ops team that will have a series of iframes pointing to a couple of Kibana graphics. The website will have, lets say, 4 links, each pointing to a a specific ...
1
vote
2answers
72 views

Refresh web page VS 'caching' idea tradeoff when creating/retrieving/updating/deleting (CRUD) data between web app and database

Design 1: For a web application. In the past, if I insert a record/data in UI, I will save this new data to the database, then the UI will be reloaded (like clicking browser refresh icon), but this UI ...
3
votes
2answers
444 views

Mixing JavaScript and server-side scripting

I see code like this sometimes (mixed PHP and JS in this case, but could be any server-side language): <script> var data = <?php echo $bigDataStructure ?>; // then lots more pure js ...
4
votes
1answer
423 views

How to implement option to return Blob, ArrayBuffer, or AudioBuffer from window.speechSynthesis.speak() call

Note, presently have no experience composing or modifying C++ code, which the code that will need to compose or modify is written in. Specifically, window.speechSynthesis.speak() does not currently ...
0
votes
1answer
188 views

Best practices for creating multiple HTML buttons that are used for a similar purpose

I realize this may be subjective, but I don't see any clear-cut place for asking questions on good software design principals. I'm sure there are some software patterns and anti-patterns I should be ...
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, ...
0
votes
1answer
644 views

Best practice to callbacks in OOP (JavaScript)?

For anyone who uses callbacks, how do I approach it when the method is an asynchronous setter? Here's an example class API { constructor() { this.token = null; } refreshToken(callback) ...
0
votes
1answer
55 views

Breaking apart a large javascript application that uses the object namespacing pattern

I have a mission critical Backbone application built before AMD and CommonJS were widely used. This application makes heavy use of the Object Namespacing pattern, so that that all the views, ...
6
votes
2answers
2k views

Why does Facebook obfuscate the names of CSS classes?

If you look at the source code of a website such as Facebook, you'll see many classes as such: <div class="_cy6 _2s24"><div class="_4kny"><div class="uiToggle _8-a _1kj2 _4d1i _-57 _5-...
2
votes
1answer
60 views

Should I place my app configurations in a JSON file or in a JS module?

I am building a JavaScript application where its behavior (some rules and logic) is configurable via JSON. The configurations are deploy only with a new version of the app. Currently my app, when ...
1
vote
2answers
510 views

High order functions: What's the benefit returning a function compared to a value?

In order words, what's the advantage of writing this: Listing 1 var sortBy = function sortBy(p) { return function (a, b) { return a[p] > b[p]; }; }; Compared to this? Listing 2 var ...
0
votes
1answer
266 views

ES6 and OO Desighn: It is good idea to use a class as “Interface”?

Usually on Php or in Java and in other single Inheritance Object Oriented Languages, when I am writing a software I use and Interface then and afterwards I implement the class that implements the ...
0
votes
1answer
135 views

load more and Search Logic

Firstly i hope im in the right place to ask this question. I am building a web page that allows the user to select one image from a set of a 100+. i want to display them 6 at a time and the user ...
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 ...
1
vote
2answers
825 views

JS: convention to distinguish immediate vs async methods

I normally have a laissez faire attitude on method naming conventions but now I am working on a module in JavaScript that will have some methods that can return the value directly (immediate / plain ...
1
vote
0answers
353 views

Pre-rendering a lot of images in HTML5 canvas, good idea?

A lot of things on the internet are very conflicting on how to deal with things. Here's my situation: I'll be building a client in javascript, using the HTML5 canvas, the canvas will contain ...
0
votes
0answers
285 views

How to load large 3D array onto memory in Javascript

In my three.js javascript, I use input, file type to load large text file(~173MB) containing calculated my results. Then I used numjs to parse the text into a 200*^3 3D float array. I hold this 3D ...
0
votes
2answers
122 views

Do Adobe PDF Actions get detected as JavaScript?

My company is creating a PDF survey (intended for other companies to complete) and we're trying to make the solution interactive (conditional checklists that become visible based on the status of ...
1
vote
0answers
47 views

How do I protect JS local scope but allow outside customization?

I am creating a javascript application that will live in a library and be used on multiple sites. I am looking for it to have the following features and need some guidance on accomplishing these goals:...
8
votes
4answers
3k views

Better ways than traditional polling methods

I'm currently in a AngularJS/Javascript environment. Currently the application using the polling method (i.e, to retrieve new data from server in a fixed amount of seconds). This is quite taxing ...
1
vote
1answer
2k views

Multiple language web application - how to implement?

What is the best way to provide a web application in multiple languages? The focus of my question is not what to think about, but indeed how to do it. The text in the web application: text in the ...
-5
votes
1answer
125 views

Variables Naming in Javascript and PHP

Is it a good idea to use the same naming nomenclature (e.g. camelCase) for both front end (eg. Javascipt) and backend (eg. php) ?
1
vote
1answer
1k views

Why tabs are evil in ES6? [closed]

As I have recently started using ES6 in production, I was going through an ES6 style guide (having more than 350 stars on GitHub). This guide mentions at least three times that "Tabs are evil. Don't ...
-5
votes
1answer
664 views

How does the typescript transpile function work

Assume the following: /// file.ts var x = "hello"; x = 1; console.log(x); /// file.ts function transpile(fileName) { ... } What steps would typescript take to transpile the file? How and when ...
-5
votes
1answer
641 views

What are the benefits of using Jasmine Framework on existing applications?

I got one project which contains JavaScript code. No unit tests were written for JavaScript code. So it is feasible or beneficial to write unit test cases using Jasmine Framework for code? What are ...
0
votes
1answer
81 views

Framework accepts Promises or executor functions

When designing a framework API is it better to have something that accepts Promises or have executor functions and have the framework build the promises when needed. The Promise API is defined by ...
71
votes
4answers
20k views

Why do many software developers violate the open/closed principle?

Why do many software developers violate the open/closed principle by modifying many things like renaming functions which will break the application after upgrading? This question jumps to my head ...
3
votes
2answers
1k views

Child object calling a parent's function through a global variable

I have a Session object, of which a single global instance session holds the current session, which can persist itself to the server, handle undos redos etc. The session holds an instance of Objects ...
1
vote
2answers
408 views

Does making a react flash message globally accessible break any conventions?

I read this article where it describes making a flash message in a react app: https://medium.com/@veelenga/displaying-rails-flash-messages-with-react-5f82982f241c They mention adding a reference in ...
-1
votes
1answer
2k views

How to get machine client information from web application?

I am writing a ticket system in PHP(with Laravel) for about 350 users and around 200 machines. I know that already are good solid solutions available, but I'm doing some very useful projects to learn, ...
5
votes
4answers
2k views

How do I know if my async function is truly asynchronous?

I'm writing a function in the node.js-style asynchronous way, but how do I know if these functions are truly asynchronous, i.e., that they run in parallel and not sequentially? Here is my code (...
1
vote
2answers
152 views

Tabular Website Design with Continuously Added Content

I'm currently working on a site for a friend, converting a google sheet to a webpage (to reduce the time it takes to modify the spreadsheets and apply them to all users). One particular page is ...
0
votes
3answers
177 views

Same JavaScript on different web pages

I have a web site with several web pages. Each page requires some JavaScript: i.e. different JavaScript for different pages, which some JavaScript that's common to every page. Some of the JavaScript ...
1
vote
1answer
313 views

The format of an response in ajax — any convention/recommendations?

Say I have a lot of page with ajax. Is there any convention or recommendation on the format/structure of an ajax response? Namely, if there's an error, a server returns http status 4xx or 5xx and... ...
-2
votes
1answer
475 views

Should objects be singular since arrays are plural?

Might be a silly question, but what is more logical: object.actions.bark() or object.action.bark()? Simply about plurality. I know arrays are usually pluralized. But if I were to be consistent; ...
-1
votes
1answer
167 views

Modelling research paper data in JSON

I need to design an UI to edit a research paper, I don't have enough knowledge about the research domain but still I tried to do my best and thought to design a normalized schema. I am describing the ...
4
votes
1answer
707 views

Why is JavaScript map() polyfill so slow

According to a JSPerf snippet (and some others), default JavaScript map() implementation is 21% slower than using a basic for. Looking at the official polyfill, I immediately understand why map() is ...