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
63 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 ...
1
vote
4answers
139 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, ...
425
votes
5answers
153k views

Pros and Cons of Facebook's React vs. Web Components (Polymer)

What are the main benefits of Facebook's React over the upcoming Web Components spec and vice versa (or perhaps a more apples-to-apples comparison would be to Google's Polymer library)? According to ...
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 + ...
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
303 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
150 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 ...
5
votes
1answer
511 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']) { ...
0
votes
1answer
120 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 ...
1
vote
1answer
194 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 ...
3
votes
4answers
9k views

Javascript - Avoiding variable redundancy in nested for loops

Please bear with me, I could only explain the problem in the comments of the code snippet below. Please read through them carefully. Question at the end: I usually tend to name the variables used in ...
-5
votes
2answers
91 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....
3
votes
5answers
2k views

How to develop cross platform mobile applications with native UI and Javascript backend?

I want to build a cross platform(Android, iOS, Windows) mobile application. I want the UX of the application to be different on the different platforms so that it will be more platform specific and ...
4
votes
1answer
206 views

JavaScript functional conversion from flat list to tree

I've been going through the RxJS tutorials http://reactivex.io/learnrx/. Almost all of the exercises involve moving from a hierarchical structure to a flat structure so I thought I'd try to do the ...
-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 ...
1
vote
1answer
106 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 ...
2
votes
1answer
91 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 -> ...
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
205 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 ...
11
votes
2answers
703 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 ...
5
votes
1answer
335 views

Will ECMAScript add classes to JavaScript? What does this mean?

I heard that some sort of class system will be added to JavaScript with ECMAScript and I find that a little confusing, because I've just finished reading a JS book, JavaScript, The Good Parts by ...
1
vote
1answer
134 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
2answers
108 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. ...
2
votes
1answer
2k views

Randomly Generate Points in a Spiral Motion using Javascript

So I have a javascript program that currently gets random points, it generates a random x,y,z value around the center point, within the radius r var maxArms = 3; var i = 0; var color = []; ...
2
votes
0answers
57 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 ...
4
votes
1answer
85 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 ...
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 ...
3
votes
2answers
291 views

Shared data in functional programming

I have been working on a project in JavaScript which requires a data structure (read only), to be shared between two functions. var mySharedData = ['hours', 'minutes', 'seconds']; Now I have two ...
4
votes
2answers
612 views

Local Updates in Persistent/Immutable Data Structures

I'm getting into ReactJS and am intrigued but also confused about persistent data structures. I love the idea, but I'm not sure how to take my MV*, Mutable, Observable Bindings experience in designing ...
2
votes
1answer
178 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
45 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 ...
5
votes
2answers
249 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
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
105 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 ...
4
votes
2answers
561 views

Practices for organizing JavaScript AMD imports

Our company has been using newer versions of the Dojo framework, which have progressed to an AMD-based loader format. I'm currently trying to find logical ways to separate layer files, taking a module ...
44
votes
14answers
8k views

Is there any reason not to go directly from client-side Javascript to a database?

Possible Duplicate: Writing Web “server less” applications So, let's say I'm going to build a Stack Exchange clone and I decide to use something like CouchDB as my backend store. If I use ...
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 ...
36
votes
5answers
12k views

How easy is it to hack JavaScript (in a browser)?

My question has to do with JavaScript security. Imagine an authentication system where you're using a JavaScript framework like Backbone or AngularJS, and you need secure endpoints. That's not a ...
7
votes
2answers
2k views

Any point in using ES6 Map when keys are all strings?

Plain object keys must be strings, whereas a Map can have keys of any type. But I have little use for this in practice. In nearly all cases, I find myself using strings as keys anyway. And presumably ...
30
votes
1answer
12k views

Why should I use Bower? [closed]

I can fully appreciate the benefits of a package manager like Python's pip, Node's npm, or Ruby Gems since they're doing much more than adding files to your applications path. Maybe I'm missing the ...
-1
votes
1answer
147 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
3answers
181 views

Angular JS style guide when declaring variables

I'm new to Angular JS and working on a project with "legacy" Angular JS code. The code is about a year or half a year old. I often see stuff like this: var _link; _link = "http://localhost"; Or: ...
3
votes
1answer
102 views

How to handle a client app that connects to a TCP server and sends/receives text data bidirectionally?

I've got a conceptual question (which is probably better posted here than on StackOverflow?). I want to develop a client application that maintains a persistent connection to a server, and exchanges ...
2
votes
1answer
191 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 ...
2
votes
0answers
223 views

Authenticate Joomla user from an external app based on Node.js, Javascript and MongoDB

I have an iOS App which currently pulls in all the data from the MongoDB using a Node.js server. Currently my API / my node server handles all the data manipulation the iOS app/Swift only displays the ...
2
votes
0answers
65 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
103 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 ...