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
0answers
61 views

Packaging a HTML,JS,CSS project within an application for security.

We have a project which is designed with html,css and JS. For demonstration purposes, we have integrated the project inside a JavaFX app in the webkit browser and from there we are just loading the ...
-3
votes
0answers
27 views

Tracing code flow, on very large projects [duplicate]

I am having a project in javascript, with many thousands lines of code, spread across hundreds of files. I am looking for a way to get familiar with the structure without having to debug and add ...
0
votes
1answer
47 views

What are the advantages of RxJS Observables over promises? [on hold]

It seems to me like Observables are basically wrappers for promises with some helper methods. It also requires a huge library to go along with it. Do the benefits of these helper methods outweigh the ...
3
votes
1answer
98 views

I feel like the more I improve the structure of my program I am writing a DSL [on hold]

My project started out as spaghetti code. The more DRY and extensible I make my code, the more it looks like configuration files and code than runs them. Is that a good thing or does that mean I am ...
-2
votes
0answers
91 views

How to rate your programming skills [on hold]

I am an Electrical Electronic Engineering student and I started programming 2 years ago. I am about to graduate from University and I cant tell how skillful I am in programming. I have written a ...
0
votes
1answer
47 views

Why is the “global” RegEx flag in JavaScript considered a property of regular expression itself?

In JavaScript, RegEx objects can be instantiated with flags such as g for global matching and i for case-insensitive. Intuitively, it makes sense for i to be a property of the constructed RegEx, ...
-4
votes
0answers
69 views

Frustrated JavaScript Student [closed]

I am learning JavaScript for the first time and the deeper I get into the lessons the more I am finding myself sitting, thinking, and trying for hours to get a peace of code right. Today I am trying ...
-3
votes
0answers
44 views

Javascript object comparison

Why is obj != obj in following context: var variable = {} //any non-primitive datatype ([], {} /()/, function(){}) var obj = {a: {}} //can also be: var obj = [{}] alert(variable ==(=) obj.a) //in ...
2
votes
2answers
168 views

How to avoid circular reference in OOP Javascript?

I have a problem while working with entity framework in JavaScript. I have two classes Table and Column Class Table { Columns: Column[] } Class Column { Parent: Table } Everything works fine until ...
0
votes
0answers
27 views

Help me understand this flow for recursive function [duplicate]

This recursive function blows my mind a bit because it executes the recursive calls until it hits 1. It returns n, but afterwards it does the multiplication below it four times and returns the final ...
-5
votes
2answers
84 views

Javascript strange callBack format [on hold]

Some one could explain me what does this code mean? this someFuncion( () => callBack(someParameters) ) or this someFuncion( parameter => callBack(parameter) ) is it possible the previous ...
-2
votes
0answers
81 views

What's kind of real-time system are of high demand in software market? [closed]

Recently I'm doing some research on real-time web applications using PHP and javascript. Real-time chat and notification apps are commonly found. I would like to know what are the other real-time app ...
2
votes
2answers
92 views

Image resizing client side vs server side

When uploading a lot of images to a server, to minimize the space taken by the images, is it better to resize the images before sending to the server or upon receiving them? It seems to me that ...
0
votes
1answer
50 views

React.js + Flux, immediate response during history back/forward

In Instagram (web), when you click back/forward arrows - I've noticed that the content isn't loaded from the server and it immediately show up. After reading the docs on react.js + flux, I had this ...
2
votes
4answers
175 views

Understanding closures

I'm reading the JavaScript guide on MDN and trying to understand the usefulness of closures. This sentence helped me the most, "In other words, the functions defined in the closure 'remember' the ...
-3
votes
0answers
80 views

Password strength feedback

I'm creating a password checker. The user is entering the password in the check.php form and then the password is saved using another php add.php To validate the different policies, like character ...
29
votes
5answers
6k views

Why do we need enums in dynamically typed languages?

I was reading some code here and saw that an enum is used to store names of html tags. Why do we ever need to do this? What benefit do I get using this strategy? I know that how useful enums are in ...
39
votes
5answers
4k views

How to avoid typical “dynamic language mistakes”?

I've recently poured a couple of hours into JavaScript because I wanted to benefit from the massive userbase. Doing that I have noticed a pattern that most people attribute to dynamic languages. You ...
-1
votes
0answers
47 views

Working with JSON arrays with no keys in angularjs

I'm working with a cube that is exporting arrays that are essentially crosstabs of two columns with a third value indicating the value of the cross section. I'm pretty new to angularjs (and JavaScript ...
0
votes
1answer
54 views

One time use token Mobile / Desktop linking. How to?

I want to know if there's a way or known way to implement this: Lets say I have: a C# WinForms program a Javascript Mobile Application (Android / iOS) What I want to do is: for my C# ...
-1
votes
0answers
51 views

javaScript eval() and window[].call() security

Before I begin, yes I know eval() is evil; but I have a rather specific use case. I'd like to make sure I'm correct in thinking this won't be an issue. The program must evaluate arbitrary math ...
1
vote
1answer
15 views

In what sense does the complexity of class hierarchies motivated by static type checking?

For example, from the book JavaScript: The Good Parts, I stumbled upon this passage: Much of the complexity of class hierarchies is motivated by the constraints of static type checking. ...
0
votes
1answer
40 views

Scaling up with zeromq REQ and nodejs

In the excellent book Node.js the right way the author shows this example: const fs = require('fs'), zmq = require('zmq'), // socket to reply to client requests responder = ...
0
votes
0answers
35 views

How can PhantomJS take a JavaScript file and use it to drive the WebKit?

I have read a lot of documents and wiki pages about PhantomJS but still don't understand, how can PhantomJS take the input JavaScript code to drive the WebKit? Take the code from PhantomJS Quick ...
0
votes
1answer
41 views

Performance of changing img src via jQuery or adding as a class

Background I've been doing a bit of image manipulation recently in PHP/JS. The basic functionality is such: Web page loads, an <img> tag points to a PHP script which generates an image "on the ...
2
votes
2answers
94 views

It it a better to have the expected return at the beginning or at the end of a function?

This is a function that searches child nodes recursively until it finds one that is a text: _.findPrevText = (node) => { if (node.nodeType === 3) return node return ...
0
votes
1answer
132 views

JavaScript templating trick or treat?

I've recently been looking into using JavaScript for templating and I was wondering about the legibility of using this approach. I understand that JavaScript templating is a very common and much ...
0
votes
2answers
68 views

JavaScript Callbacks before or after exiting function?

Is there a concrete reason to prefer executing callbacks to functions before or after exiting the called function? Example function doSomethingPossiblyAsync(callback) { if ...
1
vote
1answer
107 views

The Same Behavior for Boolean and Exception

The following code uses a boolean preference active: In the active state, it does an operation which could throw an exception. On this exception, it does fall back to the non-active state. let active ...
4
votes
2answers
170 views

How far should encapsulation in JavaScript go?

I have a variable which I want to use in only one function. I can write my code like this: var theAnswerToLife = 42 var multiplyIt = function(x) { return ++theAnswerToLife * x } I have some ...
-1
votes
1answer
103 views

Would a JS framework that automatically performs ajax requests in background be useful? [closed]

For the type of applications I usually develop (AngularJS single page applications that communicate with the server side based on the REST API) there are some requests done at the start for loading ...
1
vote
1answer
51 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
1answer
78 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
91 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
51 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
39 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(); ...
0
votes
1answer
209 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 ...
0
votes
3answers
81 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
270 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
225 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 ...
-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
74 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
205 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 ...
2
votes
2answers
84 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
29 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
2answers
44 views

Ways to structure a program with 2 states

I'm working on some sort of a Level Editor but I'm not quite sure how I want to handle the two different states: The Editor state and the Player state. In this first state game elements can be moved ...
1
vote
1answer
131 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
169 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
45 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
37 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, ...