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
23 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 ...
4
votes
2answers
79 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 ...
0
votes
3answers
120 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{ ...
-4
votes
0answers
19 views

Database Structure for Agents commission payouts generation with TDS deduction

Actually I am creating this for the first time to generate the commission payouts for agents for their sale. Commission need to be generated when the product is sold out and payout need to be done ...
-3
votes
0answers
49 views

new to JS looking for advice [on hold]

I'm a hobbyist web developer, I mostly focus on HTML and CSS and am now looking to conquer JS My girlfriend asked me to set up a website to show off her artwork (she makes birthday/christmas cards and ...
4
votes
1answer
164 views

What is a Web API?

I am doing some reading on web technologies on the MDN page. I understand how HTML, CSS, and Javascript can be used to build websites. However, I am a little confused about Web APIs. Are Web APIs a ...
-2
votes
1answer
39 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 ...
4
votes
3answers
863 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 ...
0
votes
4answers
164 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 ...
0
votes
1answer
97 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): // ...
0
votes
0answers
28 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 ...
-2
votes
0answers
68 views

Using Javascript popups to create a workflow for legal experts writing and editing legislation [migrated]

I suppose this is a ui-flow question. I'm currently working on a project where a couple of the stakeholders are suggesting the use of popup windows, i.e. browser tabs, to create a workflow to ...
6
votes
4answers
428 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 ...
0
votes
1answer
114 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, ...
1
vote
1answer
78 views

Javascript and HTML decoupling

Based on the following snippet HTML <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>Name</th> <th>Position</th> ...
2
votes
1answer
65 views

REST Standard for changing SPA Model after fetched from REST API

Let's imagine. I have following data from database. ====================================== id | Title | parentId ====================================== 100 Asia NULL ...
5
votes
2answers
162 views

Idiomatic way to write JavaScript class that maintains state and tells you when that state has changed

I am an experienced C++ developer but new to JavaScript. I want to write an ES6 JavaScript class that maintains state. How do I tell when state has changed? I can think of two ways to do this. One ...
-1
votes
1answer
79 views

Javascript Closures to Separate Class [closed]

PROBLEM: In Javascript I use closures to encapsulated methods inside a class. It helps building hierarchy inside and minimize amount of methods at root, but they become lengthy. RESEARCH: Applied to ...
2
votes
1answer
44 views

A JavaScript IIFE prevents leaks to the global space as a closure? Is that the correct concept?

I see in the code or sometimes people talk about it, for some JavaScript code: (function() { var something; function someFunction() { // some code here } // do something ...
-2
votes
1answer
199 views

Functional programming, and pushing item to array [closed]

I'm studying functional programming and I'm having some question concerning array population. Actually, I'm trying to rebuild the Array.prototype.map function, and here's what I've got: ...
3
votes
1answer
68 views

In SPA what happens in terms of memory and performance when user hops across all the pages?

Imagine a humongous web aplication built using Single Page Application framework such as AngularJS. With its each route it downloads a couple of HTML template files. Each of these template files ...
3
votes
1answer
80 views

Client Side Filtering or Server Side Filtering

So I am building a web-app. The app will be hosted on heroku and I using a MEAN Stack for development. The main purpose of the app is to allow users to search through data and be able to find a ...
3
votes
1answer
87 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 ...
1
vote
0answers
65 views

Function to return a string - Which is cleaner? [migrated]

I was having a discussion with my coworker about a function that returns either an empty string, or a string of a css class. The function is passed an object which has an HTTP status code, and then ...
0
votes
1answer
167 views

Confusion over Node as a “script” vs Node as a “server”

As I was beginning to tool around a bit with node, I was told that I needed to undergo a little bit of a paradigm shift since I was coming from a PHP background. I would ask questions like, "I have my ...
1
vote
1answer
101 views

Suggestions for structuring complex json structures?

I can't find many tips for how to design complex json structures beyond the obvious tips of not trying to nest too deeply, using defined data types, etc. For example, if I have a location that needs ...
2
votes
1answer
107 views

Should constant values be in SHOUT_CASE when there is language support for them?

Referring primarily to here, it suggests that values which are constant in JavaScript (using the keyword const) should be named in SHOUT_CASE. I'm of the opinion though that mutability is much more ...
2
votes
1answer
43 views

Convention to where to declare module.exports on Javascript files

Is there any convention to where we should declare the module.exports no Javascript/Node.js module files? Should it be in the beginning of the file like: module.exports = Foo; function Foo() { ...
0
votes
1answer
98 views

When to use “is a” or “has a”? [closed]

In my node.js application, I have a queue class which has push and pop methods and a data property. I have an Event class which handles an event and pushes it on to the queue. If I think object ...
1
vote
1answer
130 views

Javascript Closure Style Similar to Java Class Structure

PROBLEM: There is a coding imperative (S. McConnel, Code Complete) that one shouldn't code on language, but by means of it, e.g. doing right style things even if language doesn't have some ...
2
votes
1answer
58 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 ...
0
votes
1answer
84 views

Handling multiple asynchronous events - Wait for pending offers to process on new offer?

I have a programming problem, that I don't know how to solve. And while I have provided a sample of my code, I am interested in a conceptual answer on how to resolve this problem. On a tradeOffers ...
3
votes
1answer
123 views

Filtering request and responses in RESTful MEAN stack

I have a very basic RESTful service written using the MEAN stack (MongoDb, Express.js, Angular.js, Node.js) and utilizing the Mongoose ODM. Product schema var productSchema = new mongoose.Schema({ ...
2
votes
1answer
47 views

Should I be returning promises from any function that uses them?

Promises is a fairly new pattern for me, so I'm still building my intuition for them. I recently came across a case where some code in an adapter-like bit of code was once synchronous, and then ...
-4
votes
1answer
122 views

different between ES6 and Javascript

What is ES6? Is it JavaScript? Or multiple language supporter? I searched for it but can't understand it, especially the page on Wikipedia. Is it better than Javascript? And what can I do in my web ...
-1
votes
0answers
44 views

Bind and trigger an event in jQuery pattern [migrated]

Commonly I bind an event with jQuery and then call it immediately afterward, such as when I set up positioning or visibility of some elements and whatnot. $('#myElement').on('click', function () { ...
3
votes
1answer
95 views

Javascript Promise chaining [closed]

I recently started working with JS Promises. What I always like to do, is create function, which returns a Promise with the final desired result, but I only do 1 operation/then. Consider something ...
0
votes
0answers
55 views

AngularJS and NodeJS required version

I am new to the world of Javascript and their frameworks, and I feel a bit lost with this. I am trying to follow the official toutorial of AngularJS. In one of the first sections, it reads Install ...
-4
votes
2answers
83 views

Technology like SignalR but client side [closed]

I would like to program a software that will heavily utilize client side development (JavaScript), and I want to communicate with the server. Is there a way similar to SignalR where I can keep ...
1
vote
1answer
63 views

Separating Web API and the client application in .NET [closed]

Up until now I have created my .NET Web API projects with both the API and client code in the same project. In this next project it is important that I separate the two into their own projects. The ...
3
votes
1answer
202 views

Why doesn't ES6 have thin-arrow functions?

ES6 added fat-arrow functions (=>), which have two major differences from normal functions: shorter syntax (including implicit return if you use a single-expression body) inherit this from ...
2
votes
2answers
103 views

Methods of separating front and back-end with full stack javascript?

Suppose I have a front-end which is mostly a single-page application written using angular, grunt, and bower. And suppose I have a backend, which is mostly just a REST API sitting on top of an ORM, ...
-2
votes
1answer
50 views

Is it better to have a single, more general directive or multiple type based directives in Angular?

Is it considered good practice to have: Single, general directive that has multiple data-* parameters and serial data is binded from controller Single, general directive that has config and serial ...
9
votes
3answers
226 views

How do you use duck typing in javascript without always checking for properties and methods?

I know javascript uses duck typing and at first I thought this would make polymorphism easy compared to strongly typed languages like C#. But now my functions that take arguments are littered with ...
2
votes
2answers
109 views

Will Web Components in HTML Add Too Much Complexity? [closed]

The way I've been accustomed to User Interfaces is to see everything as a div. Where a div is essentially a box and they can be stylized in CSS. <div class='container'> <div ...
2
votes
2answers
175 views

Is equating a variable to a function that takes the same variable bad programming?

Is it improper programming to set a variable equal to the result of a function that accepts the same variable? The languages in question here are c#, javascript and PHP (not sure if this works in C ...
5
votes
1answer
81 views

Strategies to maintain contract between mocks and APIs

Using a mock instead of hitting a 3rd party API like Postgres or Stripe can often be necessary when writing tests. A problem I've seen is when the API can unknowingly diverges from the data the mocks ...
4
votes
1answer
129 views

What is the most efficient way to implement a RESTful client app?

I am working on a web application for ranking some products based on some factors. The user send a search query to 5 restful webservices which by their turn send a response in a JSON format and ...
2
votes
2answers
122 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: ...
2
votes
1answer
79 views

Is it possible to not have a zero-indexed array with javascript? [closed]

I've been coming across some interview questions that mention within the question "... given an integer x and a zero-indexed array..." Is it necessary to mention zero-indexed array? What languages ...