JavaScript is the original and common name applied towards most flavors of a scripting language that originated on NetScape Navigator. Use this tag for questions regarding common implementations of ECMAScript, JavaScript, JScript, etc. JS does not typically refer to its ECMA-cousin, ActionScript.

learn more… | top users | synonyms (1)

0
votes
1answer
20 views

Validating transaction codes with reference codes… Best way to encode the validation rules?

Good Day, I have a series of reference codes that my end users create during the course of the day. These reference codes correspond to a transaction code that is stored in a database. As of now, ...
-2
votes
0answers
26 views

Client-side template engine when working with Spring and Javascript on the client side?

We're creating a web app and we're using Spring(Boot) on the server-side and Javascript and JQuery on the client-side. On the server-side we're using the template engine Thymeleaf, since it was ...
2
votes
1answer
30 views

Which IndexedDB data structure for Chrome app?

I'm on the way to build a Chrome app, dedicated to fulfill shop/marketplace orders. The orders come from marketplace APIs like Amazon MWS. The data is stored only in the app (with backup). The system ...
0
votes
1answer
82 views

How to handle extra arguments in a JavaScript library?

JavaScript is the only language I've come aross which allows variable-length argument lists by default. A case where it would be helpful to detect too many arguments would be Mozilla's Add-On SDK's ...
1
vote
1answer
28 views

(react.js) when is it appropriate to call stores from non-container components

I believe most people are in agreement that using container components is a good practice - described in this popular post: https://medium.com/@learnreact/container-components-c0e67432e005#.qhw8yfodx ...
0
votes
1answer
32 views

jQuery, deferrers and “if” conditionals

How could I simplify the following code? I suspect that it can be simplified by using the $.Deferred class, but I don't know how. if (condition) { $.get('url').done(function () { done(); ...
-1
votes
1answer
180 views

My algorithm is too slow

Reposted from Stack Overflow - I think this is a more appropriate place to ask the question. I have an algorithm that for an integer x and a starting integer i such that 1 < i < x the next ...
-3
votes
0answers
39 views

Where does client side web application framework fit in [on hold]

I have been working with java based web application frameworks like JSF,spring,hibernate for few years.Off late I have been hearing a lot about javascript based frameworks like angularjs for client ...
0
votes
3answers
74 views

Design for a function to skip a step if called multiple times

Terrible title, but this is the situation I find myself in often and have not found a good design to make it nice. Lets say I'm working with Javascript and I have an object I am working on that needs ...
2
votes
1answer
261 views

What should I call this utility function? Is something like it commonly used?

Suppose you want to combine some arrays of objects that have similar properties: var people = [{name: 'Jack', age: 10}, {name: 'Jill', age: 12}] var items = [{owner: 'Jack', name: 'pail'}, {owner: ...
2
votes
2answers
211 views

Are there any reasons not to ever use classes or ids anymore?

I sort of understand unobtrusive javascript. Even in my CSS now I hardly ever use classes or id's because I like clean, easy to read, uncluttered html files. For example, why use this: <body ...
0
votes
0answers
78 views

Are there any attempts to fix the flaws of javascript? [closed]

Javascript has some known terrible design flaws, most notably: The == operator Automatic type coersion Optional semicolons Dynamic typing Are there any compile-to-javascript languages that fix ...
-3
votes
0answers
43 views

Is investing time in WinJS worthwhile? [closed]

I was wondering since last few days that JS is now becoming so popular these days. Node.js has opened new horizons. I was wondering if JS can be used to build windows gui apps and I came across WinJS. ...
-2
votes
0answers
26 views

How to dynamically limit the number of elements on a row in D3.js [migrated]

I'm fairly new to D3. I'm wanting to develop rows of rectangles with 4 rectangles each row. For example, if I had 8 data elements, it would draw 2 rows of 4 rectangles. If I had 9 data elements, it ...
1
vote
2answers
62 views

TypeScript/ES2015: Prefer `const` instead of `let` reduces readability?

ES2015 introduced the let and const keywords, which essentially have the same semantics apart from reassignment. (const can be seen as a final variable in languages like Java.) I see the point of ...
2
votes
2answers
195 views

Is it a bad practice to use JSON strings as keys of objects?

On languages such as Haskell, most datatypes have instances which allow their values to be used as keys of structures such as Maps. JavaScript has reasonably fast maps, there called objects, but those ...
-4
votes
1answer
66 views

pick new item from array every day [on hold]

Let's say I have an array of any fixed length i.e. it could be 3, 5, 7 ... upto 30. How can I generate an algorithm such that if I pick an item from the array, every single day, it should not pick ...
2
votes
2answers
59 views

Client-side Rendering vs JSP's for Spring MVC Front End Dev

Firstly, a note on the app I'm about to discuss: It's quite large, on the order of magnitude of a service app like Airbnb -- i.e., it's not just a static web page, it is a full web application. It's ...
0
votes
0answers
25 views

Event dispatcher and state

I'm using an event emitter similar to Node's, with the following pseudo code: event.on('onFuncBegin',(e)=>); event.on('onFuncEnd',(e)=>); let myFunc=()=>{ ...
1
vote
1answer
122 views

Returning functions within Javascript objects

After coming across Douglas Crockford's views on class-free OOP, and doing away with new and this in Javascript I tried defining an object with its own variable and function, and returning it in a ...
0
votes
4answers
166 views

Naming convention for method that may carry out an action

I have a method in that checks some conditions and if required, will carry out some logic to empty an array of 'selected' elements. Is there a standard way to name such a method? I was thinking ...
1
vote
1answer
42 views

Template Literals (ECMAScript 2015 6th edition), are they worth it?

I recently found out about JavaScript's Template Literals, and they help a lot with readability. But would it be worth changing my code from now on to these Template Literals, or should I keep using ...
0
votes
0answers
34 views

Code structure for complex UI module with strongly bonded components

I'm trying to figure out a new approach in organizing my code structure. Let's say I have a single-page module which UI consists of: form with search filters, very interactive table (paginated, ...
44
votes
8answers
6k views

What are the drawbacks of making a multi-threaded JavaScript runtime implementation? [closed]

I've been working on a multi-threaded JavaScript runtime implementation for the past week. I have a proof of concept made in C++ using JavaScriptCore and boost. The architecture is simple: when the ...
1
vote
1answer
55 views

Error handlers inside Promise.all

I'm looking at this piece of code and whilst it works, it feels wrong to me. I'm wondering if I am looking at an anti-pattern? The code starts with two promises, getAccounts and getTransactions. On ...
-5
votes
0answers
84 views

How do I create an HTML form that emails me the input? [closed]

I would like to create a simple HTML form that emails me or sends me the input of the form without showing the user. I have managed to create an HTML that does that, but when you click "submit" it ...
-3
votes
0answers
43 views

Making Div Tabbed Panels in Javascript

I have a website that needs to dynamically generate div tabs based on user input. Currently, this is the code I have to generate a single div: var div = document.createElement("div"); ...
1
vote
1answer
54 views

Java 8 Optional in JavaScript

I like the idea of Optional in Java which we can use to say that the object may or may not be available. I am now learning JavaScript and when trying to find an equivalent, came only across ...
1
vote
1answer
62 views

Best practice for storing external text to then place in html

Sorry if I'm not explaining the question well in the title, I'm not sure of the correct lingo. Let me give you an example instead. So this is a normal HTML file. <span>Well to the ...
0
votes
0answers
22 views

iron-ajax chaining polymer

I am looking for a way to nicely chain promises in polymer. Now I define a method in my on-response to send the result of my first request to. Upon response, I fire my second request. This flow makes ...
-1
votes
3answers
179 views

Are browser console errors 'compiler errors', 'runtime errors', or neither?

I was trying to communicate with a coworker about a JavaScript error I was being notified about in my browser's console window when I realized that I wasn't sure if I should refer to this as a ...
0
votes
0answers
23 views

Syncing file data and form data uploaded at separate times

I have a web application where users can upload office documents. In addition to uploading files users also specify extra information about them that's not contained in the files themselves but is ...
2
votes
1answer
115 views

When making a change to a single table in our app, should we minimize the scope of our change, or follow best practice for css/jsp coding?

My co-worker has been assigned the task of editing one of our Java application's tables. She is almost done, but needs to make one final adjustment to the table - this requires her to add a CSS ...
0
votes
3answers
97 views

Does setTimeout() really execute in parallel?

Consider following JavaScript code: function foo(ary) { // some long operation on ary } function bar(ary) { // some long operation on ary } function baz(ary) { // some long operation on ary } ...
0
votes
1answer
53 views

Should models be returning data directly to the client, or to the controller instead?

Disclaimer: This is my first time: using node, creating a REST API, and trying out MVC server side. (so, just statistically speaking, I'm probably doing something wrong ¯\_(ツ)_/¯) I'm working on ...
4
votes
2answers
74 views

What does “initialize event handler” mean in this context?

In file1.js I read: // NOTE: initialize your app event handlers here, see file2.js for a simple event handler example // TODO: configure following to work with both touch and click events (mouse + ...
12
votes
3answers
280 views

Providing Local JS and CSS Resources for CDN Fallbacks

Given that CDNs are a Good Thing because they can serve resources closer to the client, the client can cache them, and you can reduce load on your own server. In recent browsers, loading resources ...
-5
votes
0answers
57 views

Programmatically scrape Quora's reading list

Making a get request to the URL will only fetch some questions/answers but not the ones which are received in subsequent Ajax requests. How can I programmatically get all questions and answers in my ...
2
votes
2answers
57 views

Cleanly generating several 0-airty JavaScript functions with slightly different bodies

Say I have a bunch of JavaScript functions similar to: message = [“000”, “111”, “222”, “333”]; function F0(){ alert (message[0]); } function F1(){ alert (message[1]); } function F2(){ ...
1
vote
3answers
132 views

Where should I do localization (server-side or client-side)?

I am currently developing a new web application based on a rich JavaScript client which communicates with multiple REST web services on my server. That application is intended to be used in at least ...
0
votes
3answers
138 views

Which of these promise methods is considered a best practice?

I have a couple of async method that is basically a yes and no reply isUsernameAvalible() isOnline() isImage() yada yada... you probably get the point by now. As a demonstration... try to think of ...
-3
votes
1answer
68 views

How to compare and replace value from two object inside array?

Here i want to replace price in data1 to price from data2, and it updated if the id is same. Is it possible to do that without nested loop? var data1 = [{ "id": "56e641d4864e5b780bb992c6", ...
0
votes
1answer
88 views

Drawing a data-grid on canvas - whats the point?

To simplify my question let's assume for a minute that all users are using the latest version of Chrome to view a particular website. Using the latest libraries (Polymer for example), I can render a ...
5
votes
1answer
425 views

What does Google mean here when they say “don't copy and paste this code”?

Here is an excerpt from code from Google's recaptcha API (https://www.google.com/recaptcha/api.js): /* PLEASE DO NOT COPY AND PASTE THIS CODE. */ (function() { if (!window['___grecaptcha_cfg']) { ...
-5
votes
2answers
85 views

How do I make such a page that opens different link in web (PC) and different in mobile (phones)?

I am building a website that looks beautiful in Web but worst in mobiles. I want to build the same site but different designing for mobile. Whenever user opens site.com then it auto redirect to ...
-4
votes
2answers
139 views

How to find all occurrences of a variable within a source code?

The title is pretty self-explanatory. I have a minified JavaScript code (100k+ lines) and would like to find all occurrences of a particular variable so I could rename it to better understand code. Is ...
2
votes
1answer
68 views

Why does JavaScript console.log of objects sometimes show prototype/constructor pattern forever

I've always noticed this, but never actually understood what's happening here. I have a fairly simple object that I've put in a console.log. It has a seemingly never ending pattern of prototype -> ...
1
vote
1answer
150 views

How should I implement a full text search into my meteor web app?

I am making a web application using the javascript framework Meteor, which runs with mongodb. In the web app I have a db set up that holds individual video games in the documents. An example of this ...
7
votes
3answers
1k views

Is a function getting a value from another function considered pure?

I'm trying to figure out a way to handle default variable values when making functions without side effects and have ended up with the following: function getDefaultSeparator() { return ':'; } ...
-1
votes
4answers
161 views

Nested For Loops JavaScript

I have an app which gets data from the database (MongoDB) in JSON format. The returned data contains nested arrays and I want to access the values in the nested arrays. The returned JSON format looks ...