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)

2
votes
1answer
119 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
142 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
62 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
86 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 + ...
14
votes
3answers
318 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 ...
2
votes
2answers
58 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
256 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
145 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
98 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
112 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
487 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
90 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 m.site....
-4
votes
2answers
146 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
82 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
180 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
195 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 ...
0
votes
0answers
48 views

Deciding on a Portable Platform (given a set of requirements)

Background Before asking this question, I researched this site and found the following 3 most similar questions have already been asked: When would using a scripting language within a larger program ...
0
votes
1answer
89 views

Can a browser script detect SSL MITM?

Is there a standard mechanism for javascript to detect TLS MITM? I'm looking for something along the lines of reading the fingerprint for a server cert out of the browser, and comparing to an inlined ...
9
votes
2answers
512 views

Benefits of Structured Logging vs basic logging

We're building a new app and I'd like to include structured logging. My ideal setup would be something like Serilog for our C# code, and Bunyan for our JS. These would feed into fluentd and then could ...
2
votes
2answers
106 views

When should I nest one module inside another?

Assume I'm working on a JavaScript application and make extensive use of the module pattern with one file per module. Now suppose I have two folders/modules: one for module A and another for module B. ...
1
vote
1answer
133 views

For Web front end, if there are 20 JavaScript files loading, how to track down the mouseover handler?

For Web front end programming, since any JavaScript can set up an event listener for "mouseover" or "mouseenter" for an element, if we are to track down what is the code that is responsible for making ...
2
votes
0answers
54 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 ...
0
votes
0answers
58 views

How to effectively log while avoiding a bottleneck

I have a fuzzer for x86 Internet Explorer (in HTML) that I've heavily modified to have reproducible, determinisitic crashes (so that I may perform root cause analysis faster). I'm attempting to ...
2
votes
0answers
105 views

Best way to verify that a user has completed a task on another website.

We are developing a website for students on which they first have to fulfill specific tasks in order to use our service. The problem is, that those tasks are on another website, which has nothing to ...
1
vote
4answers
132 views

How and where to test if the JSON request objects generated by the front-end is valid

We have built a complex Angular application that sends multiple HTTP request to a REST service that is also built in house. Since both the frontend and the backend is being developed in parallel, ...
4
votes
1answer
84 views

What is the best way to selectively load transpiled code or polyfills for downlevel browsers?

There's no escaping Internet Explorer 11 as it will be around until 2023 as the default browser of the most popular desktop operating system. Yet, Internet Explorer 11 will not get new updates to ...
2
votes
1answer
165 views

Redistribution in binary form - Copyright notice in Javascript

I want to distribute a single exe file, which is a simple http web server. This exe contains all the dependency html/js files (mostly licensed under MIT and New BSD) I really don't know if that's ...
23
votes
2answers
1k views

Why is passing large anonymous functions as arguments to other functions so widely accepted in JavaScript?

I have an opinion (which I am sure will be shared by some) that passing anonymous functions which contain more than a few lines of code, as arguments to other functions affects readability and self-...
2
votes
0answers
44 views

How to architect rule matching with multiple conditionals and outcomes

I'm working on allowing my users to create their own ruleset for data that's coming in. All of the data below is sample mock data and not in relation to our product. Example of a rule (there can be ...
2
votes
2answers
106 views

Generate pips on a die based on value

Is there an algorithm to generate the pips on a die or domino? I know that there is usually an odd number of columns and even number of rows (unless the max number of pips is not a perfect root). ...
2
votes
0answers
102 views

Javascript: How to get the Object an object is prototype of

Javascript in the DOM has a peculiar characteristic. There's a different Object object that an object (by default) inherits per window. In order to find what kind of object is being sent to a ...
15
votes
0answers
723 views

Is there a reason for not using JavaScript for direct database connections on a web site? [duplicate]

I am thinking about using JavaScript for direct connection to our database server. I think I have solutions to all the possible problems about it. Security: Modern database management systems ...
1
vote
2answers
79 views

Software design for Client side form validation

So Im using the MEAN framework to build my web app. Like all other apps it requires a login & registration. My Approach so far has been: Every major function of my app has its own AngularJS ...
1
vote
1answer
96 views

What is the approach for implementing FLUX in a CRUD application that pulls JSON data from the server?

While using FLUX in a CRUD application, according to what I understood, initially the data is returned from an AJAX call and then stored in the STORE. So, all the data that is currently viewed is only ...
-1
votes
1answer
146 views

Showing a “context”-like menu in a span

Context of the question (some people believe it is useless to give such details, so feel free to skip them) It is about the MELT monitor (an alpha-stage GPLv3 free software, see also here). FWIW, I ...
2
votes
1answer
188 views

Any reason to continue using plain strings in ES2015?

My current coding style is to use single-quoted strings as a default, and use backticked template literals whenever I need to concatenate a value into a string. But I'm now wondering what's the point ...
5
votes
2answers
232 views

Respectable design pattern for making node modules flexible/testable?

I am looking to get some input from some more experienced testers than what I am. :) I am trying to make my node modules testable, allowing for dependency spying/stubbing/mocking without the need to ...
2
votes
0answers
64 views

Suggestions for Storing large collection of related words

I am trying to create a simple sentence generator that uses templates and a database of words. It will be a website where essentially a user could click a button to generate a sentence. For example: ...
1
vote
3answers
97 views

Is synchronously inspecting a promise an anti-pattern?

ES6 native promises do not allow you to synchronously check if they're resolved/pending/failed or to extract their value. I sometimes need this functionality and thus I have to code it manually. Is ...
1
vote
1answer
157 views

Is there any value in using a Promises library versus ES6 Promises?

I see a lot of NodeJS articles recommending the Bluebird library for promisifying your code and avoiding callback spaghetti. Is there any value in using such a library when using Node 4.2.4+ given ...
5
votes
2answers
162 views

Is Module Pattern in JavaScript is useful only for singleton creation?

Some articles (JavaScript Module Pattern In Depth, Mastering The Module Pattern) describe defining modules in JavaScript like in the snippet below (from Addy Osmani's "Learning JavaScript Design ...
1
vote
3answers
159 views

How far should I validate user input in my own created API?

I got something here that bogs my mind a bit. Let's say I write me this API (in TS), check out some of these properties: export class MyAPI{ propertyThatShouldContainSuffix:Array<...
-1
votes
1answer
50 views

Javascript: Effect of passing entire object vs a property of the object as argument on performance

Does passing the entire object as argument rather than just a property of it, in javascript, effect performance? For example: <input type="button" onclick="getDetails(this)"/> vs <input ...
6
votes
3answers
1k views

Is break a code smell?

I'm asking in terms of a loop, obviously break is important in switch statements. Whether or not switch statements themselves are code smells is a separate issue. So consider the following use cases ...
1
vote
4answers
192 views

How does this function returning a function work?

I'm having a hard time understanding exactly what is happening in the code here and how this script is changing other functions. This is taken from eloquentjavascript.net chapter 5 on higher order ...
1
vote
1answer
334 views

JavaScript & AngularJs Modules Implementation technique and structure

So Im building an app and I'm trying to implement the structure of the app so that its robust and scalable in future. My app is mostly divided into JavaScript Modules (revealing pattern): // filter....
0
votes
0answers
43 views

How to get dual UI for an ionic app?

I would like to get some suggestions for building a new app. This app has two faces/UI to it, buyer/seller. Users would have same account, and it would be seller and buyer. Its something similar to ...
7
votes
4answers
485 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 ...
2
votes
1answer
360 views

Consuming REST services: client or server

I am working on a new project in which we are currently deciding which technologies and frameworks we will be using. The application will eventually be cross platform. Therefore, for the server side, ...