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
19 views

Why would I need node.js to run a javascript library?

I'm interested in using sigma.js, and I'm looking at the instructions here: https://github.com/jacomyal/sigma.js/wiki One of the prerequisites is that node.js is installed. If it's a client side ...
5
votes
3answers
266 views

Unit Testing Competition [duplicate]

My employers runs a monthly unit testing day competition. One entire day is dedicated to writing unit tests -- obviously we do more testing throughout the month, but this is an entire day -- and the ...
-3
votes
0answers
13 views

Javascript Function to change Image source? [migrated]

I have been lurking for a bit but it's my first post here. I am trying to have a JavaScript function that will change images by clicking on them, without needed to use multiple HTML pages. From my ...
0
votes
1answer
68 views

What pattern to use when you have to hide/show different sections on a form depending on a dropdown value?

For example, let's say you have 8 sections to hide/show and depending on the value of a dropdown, you have to show or hide dynamically from 1 to 8 sections. 1) Is there any better way of doing this ...
0
votes
0answers
29 views

Looking for a way to interpolate a base URL that won't conflict with Underscore template code

At my workplace, we have dev and production environments, and a separate server that serves static files for each environment. In my code, I make references to the URL of this static file server. ...
-3
votes
0answers
31 views

Right language for a game [on hold]

I want to make a simple card game that takes 2 to 4 players. I want to make the game online so that real people can play each other. I prefer to make this game over a website rather than code an .exe ...
0
votes
1answer
68 views

Separating front end and back end using private api php

I am using php only for basic CRUD operations with MySQL. I want to create private API in php. From what I came to know , these are the steps for a developer local server to get data from remote ...
-2
votes
0answers
33 views

“make” or “create” for factory functions? [on hold]

Say I have JavaScript functions that assemble objects. They implement a variation of the Factory design pattern, except they are independent functions, not methods of an object. Should I name them ...
0
votes
1answer
82 views

Ideal export in terms of size for asynchronous module definitions in JavaScript?

When creating AMD modules you can export whatever you like whether it be an object or a function. I vaguely recall reading a recommendation somewhere to export just one thing; the idea being "keep it ...
31
votes
1answer
112k views

What is the best way to include JavaScript file using script tag?

I generally include JavaScript files using the script tag as below. <script type="text/javascript" src="somefile.js"></script> I have seen some people using the language attribute as ...
1
vote
3answers
113 views

Auto-save user input - the smartest way?

I'm developing a social network website and I'm working with php/mysql/jquery and I want users to have the most user-friendly website experience. That's why I try to avoid a save (submit) button at ...
-1
votes
0answers
21 views

Building an EXT 4 tree with JSON data [migrated]

I'm building an android app that posts collected battery data to a website viewable by the app user and I'm having issues building a tree to view the collected data. I'm looking to build a tree ...
0
votes
1answer
55 views

Javascript Constants in ES6

What would be the preferred way to create constants in javascript, specifically with ES6? Currently I have a constants class which has methods that return the string I'm looking for. class ...
1
vote
1answer
185 views

Why can a constructor be used without `new` keyword in Javascript?

I found Date can be used without the new keyword. Date(1) > "Thu May 28 2015 15:54:20 GMT+0800 (CST)" new Date(1) > Thu Jan 01 1970 08:00:00 GMT+0800 (CST) I was wondering whether there is ...
2
votes
4answers
393 views

Will object reuse optimize this often-called function?

Suppose I have a function that I need to call a lot, maybe a few thousand times on every mouse down or mouse move. It uses an instance of a function (class), called Transform: function func1(a, b, c) ...
4
votes
1answer
1k views

How should I structure modules in an Angular.js application?

I am fairly new to Angular.js, and one that confuses me is how to best use modules in an application. It seems to me that modules can contain any of the other common constructs in AngularJS ...
1
vote
1answer
74 views

html/css/javascript for game ui's

I've been looking into game ui's recently. My conclusion is that html/css/javascript would be the perfect solution IF it was wrapped up in a nice C++ library that allowed for easy integration into ...
10
votes
2answers
2k views

What are my choices for server side sandboxed scripting?

I'm building a public website where users share data and scripts to run over some data. The scripts are run serverside in some sort of sandbox without other interaction this cycle: my Perl program ...
2
votes
1answer
478 views

How many Angular Controllers and/or Directives is too many?

I'm building a large, editable data table with angular, and I'm trying to figure out what the best practice is. The table will be a couple of hundred rows, with a couple of dozen columns, so upwards ...
-4
votes
1answer
90 views

Should I remove logging statements on production? [closed]

I have a bunch of console.log statements in my AngularJS app. Should those be removed for production? Are there potential issues from leaving them on?
1
vote
1answer
129 views

How do I design a Javascript Object to not use any public properties?

I have been playing with the Object creation outlined by Douglas Crockford in his new talk "The Better Parts" function constructor(spec){ var that = otherConstructor(spec), member, ...
-4
votes
0answers
11 views

How to add custom view to markers located on a map? [on hold]

I have been working around with a store locator application built using JavaScript. I am able to locate the stores on the map but how to add a custom view to the markers of the stores so that when an ...
1
vote
2answers
87 views

In javascript, should object properties be declared on top of the function?

I learned that it's good practice to declare variables before they are used. For example: function myFunction() { var i; var j; } Does the same thing go for object properties, and is there a ...
12
votes
5answers
6k views

Avoiding new operator in JavaScript — the better way

Warning: This is a long post. Let's keep it simple. I want to avoid having to prefix the new operator every time I call a constructor in JavaScript. This is because I tend to forget it, and my code ...
1
vote
1answer
117 views

Differences in design/thought process for OO in Java and JavaScript [duplicate]

Despite sharing a similar name and syntax, Java and JavaScript are quite different. However, they both have Object Oriented features. As a JavaScript novice, the main differences that I can see ...
-3
votes
2answers
143 views

JavaScript form validation without clicking submit button [closed]

I want to validate a form using java script before user clicks the submit button. <form role="form"> <div class="form-group"> <label for="email">*Email ...
13
votes
5answers
846 views

Can *any* program task be expressed without state?

This is a theoretical question, but after many years of programming in what I now realize is "normal" imperative technique, using C++ mainly, I've discovered this other world of functional ...
2
votes
1answer
78 views

How to design a serverside heartbeat with nodejs?

I would post this on http://stackoverflow.com/, but figured I am not looking for code, just an idea how to accomplish this. I have a gameserver that interacts with nodejs and uses the websocket ...
1
vote
2answers
203 views

Live search/filter as you type in client approach

As an exercise for myself to practice my JavaScript "skills" I'm trying to write a client-side filter. It should be able to filter "content blocks" as the user types. By "content block", I mean a ...
0
votes
3answers
236 views

What arguments are there to use a coding style for each distinct language? [duplicate]

I recently had a discussion about our coding style for C# projects. Two things in particular were very hard to agree upon. Method Naming C# has the de-facto standard of naming (at least public, ...
0
votes
0answers
30 views

Trouble with a heightmap adjusting algorithm [migrated]

I have a 2D grid of integers. The user can pick any location and increase or decrease its number by one. The algorithm should adjust all eight adjacent locations so there is no more than a difference ...
2
votes
0answers
163 views

Javascript callback design: is it OK to have side effects?

Consider this javascript function: function(){ var someArr = [...]; var someObj = {...}; someArr.forEach(function(item){ if (matchItem(item)){ ...
2
votes
1answer
393 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 ...
0
votes
1answer
33 views

Bundling and minifying options for MVC2

I've just been handed an MVC2 application and noticed that there is no bundling or minifying of the JavaScript or Stylesheets. I've used the built in bundling and minifying logic that comes out the ...
0
votes
1answer
82 views

Measure and locate areas of similar value in an image

I saw this picture online and wanted to see if I could create an algorithm to give ordinary images an effect like this: http://justinlivi.net/wp-content/uploads/2011/01/Living_In_Digital.jpg My idea ...
0
votes
1answer
59 views

JSP in Javascript file or multiple AJAX requests

I've been thinking about how I want to load my data for some checkboxes in an AngularJS app. I'm generating multiple checkboxes based on 2 JSON objects that are currenty hard-coded in the a Javascript ...
3
votes
1answer
304 views

What is the most efficient / fastest way to keep a list in order?

I implemented Dijkstra's path finding algorithm in JavaScript and a big part of it involves storing the distances to nodes and fetching the smallest. The distances change often and the smallest is ...
0
votes
2answers
78 views

How to protect controller endpoint from abuse?

I am building a web app that will first validate a promotion code via AJAX call and then if it is valid, allow the user to fill out the rest of the form, I use KnockoutJS to reveal and hide the ...
0
votes
1answer
33 views

node deep file indexer module cannot go deep [closed]

I'm trying to make a file indexer by node.js. The program is supposed to index files and folders in an array and also check inside folders and add all sub folders and files I wrote: ...
7
votes
1answer
171 views

Why create a Global-ish Object.create function?

I'm a fairly experienced programmer in the .NET and Java realms, and I've started reading up on JavaScript. I bought Douglas Crockford's "The Good Parts" book, and I'm immediately put off by a few ...
0
votes
0answers
116 views

Right way to design javascript flow?

My question is because I believe that maybe there is a better way to design my code when I need to do sync tasks in JS and wait for the response. I'm working on Node and I need to save some data (I ...
24
votes
10answers
12k views

Why Should I Avoid Inline Scripting?

A knowledgeable friend recently looked at a website I helped launch, and commented something like "very cool site, shame about the inline scripting in the source code". I'm definitely in a position ...
28
votes
5answers
14k views

Is JavaScript interpreted by design?

I am cautious of asking this question because it might appear overly fastidious. I just opened up JavaScript: The Definitive Guide, and it states of the first page of chapter 1 "JavaScript is a ...
2
votes
2answers
189 views

Pre-Processors vs Pure Web [closed]

It seems like within the last few years or so HTML/CSS/JavaScript Preprocessors have exploded in quantity and general use. They're still not as common as pure HTML, CSS, and JS/jQuery, but their ...
7
votes
1answer
307 views

Is obtrusive JavaScript required to support a feature of AngularJS?

I'll start by saying I'm just learning about AngularJS, and I was reading this article, which seems to advocate for obtrusive JavaScript as the right thing: ...
0
votes
1answer
40 views

Is there any reason not to allow negative numbers to be entered into a JSP field labeled for positive numbers?

Our application, a fairly complicated money ledger, has a JSP field for entering a certain type of money due, balanced by payments made towards that amount due. In the application, this field is ...
16
votes
3answers
5k views

Why would I use Angular?

From the basic Angular tutorial, it seems like all it does is fetch some JSON from an API and display it. Also, there's its double binding magic. But why would I use it instead of a backend solution ...
0
votes
1answer
137 views

Why sending a file is so difficult using angular? [closed]

I have to send a file (very large file) to a server. I'm studying what options I have and how to do it. I'm using angular + express + nodejs. If I use a simple form, I could catch the file on the ...
2
votes
1answer
51 views

Reuse already fetched data for request

I have action that fetches user model from db to check access. Then I have method that in some cases requires same model. function checkAccess(req, res, next) { var data = ...
5
votes
2answers
2k views

Every function is a closure?

Wikipedia says, that closure - is a function, which has an access to variables, declared outside of the function. There is even an example: function startAt(x) function incrementBy(y) ...