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)

-4
votes
0answers
25 views

Best Web Scripting Language for Real Time Data [on hold]

I am currently developing an interactive, close to real-time(at most 2s latency) web app that has to work on mobile as well. I've been using PHP with Mysqli but I've found this to be memory intensive ...
0
votes
1answer
31 views

Using ajax for rails. Use Capybara or start using Jasmine?

I have a rails that that, like many started out life as all .erb pages. Now I am increasingly writing functions in javascript using jquery to avoid entire page reloads. Sometimes there is js before ...
-1
votes
2answers
172 views

Why can't anyone get “scroll bounce” right in JavaScript? [on hold]

I've never seen a convincing example of 'scroll bounce' in JS. Something about the friction or elasticity looks/feels unrealistic, even in simple demos for popular touch libraries. I'm not looking ...
-1
votes
0answers
35 views

Is there a good course in the Netherlands/Belgium where I can learn SPA, RequireJS & KnockoutJS? [on hold]

I have a background as a .NET/C# developer and I need to get more familiar with client side development. For my current activities, I need to become more familiar with Single Page Applications, ...
-2
votes
0answers
30 views

CSV data to Chart.js Graph [on hold]

I have a Bootstrap website to which I am trying to add a Chart.js line chart. I have an example chart working but have not added my data to the script for use in the chart. I have looked over lots of ...
1
vote
3answers
265 views

From a technical point of view, could JavaScript be compiled instead of interpreted?

The question title speaks for itself. I'm specifically thinking in terms of a Node.js server. Additionally, this question is assuming that you don't need eval(). Also, if this is not possible, why ...
0
votes
0answers
27 views

Using ng-init to initialize data in Angular controller

Recently I came across the following in one of our projects. In one of our mvc views they are passing model data to an Angular controller through ngInit directive In xxx.cshtml <div ...
-2
votes
0answers
13 views

Does the JSON parser omit empty arrays? [migrated]

I have a JSON like this: { "CODE" : [{ "FOO" : "BAR", "SET" : [] }, { "FOO" : "ABC", "SET" : [] } ] } Now, when I try to access CODE[0].SET, I ...
-4
votes
0answers
22 views

Change a Tag's Class with type submit through getElementsByTagName [closed]

I have this code: <input class="btn" type="submit"> <input class="btn" type="password"> <input class="btn" type="submit"> I want to change all input's class with type submit from ...
1
vote
1answer
226 views

What is the “best practice” for converting an external API's data structure?

When an API's data structure does not fit well with an angular app, I am trying to determine the best-practice in my specific design and implementation for converting it to a usable structure. I was ...
0
votes
1answer
102 views

Ajax call or js to update a cart price

I am building a cart in Java and would like to give users the ability to update the quantity and see the new price instantly. I am using BigDecimal on the back-end for complete accuracy, but the ajax ...
0
votes
0answers
12 views

JavaScript Print Formatting [migrated]

I'm learning NodeJS and rewriting some code to see how it compares. For one script, I am trying to take dates in the form of strings and turn them into JavaScript Date objects to perform calculations ...
-1
votes
0answers
29 views

Preview hidden options on web sites [closed]

I want to have hidden options on my web site and be previewed only when the user chooses. I want to animate them from left and right (about 15%). At the moment I have them visible in my html but with ...
0
votes
1answer
80 views

Finding “spare time” in a day from within a list of events

I have a list of events which is always sorted chronologically. The start time is always followed by the end time. Times are strings formatted as 'HHmmss'. // list of events var events = [ ...
0
votes
1answer
139 views

Cheerp — C++ for web: advance or regression? [closed]

Recently I've run into Cheerp, a C++ to Javascript compiler, which uses a modified version of clang to generate Javascript code from C++ sources. That makes me wonder: why in the seven kingdoms would ...
-2
votes
0answers
38 views

JavaScript filter PHP results [closed]

Hey guys for a while now I have been trying to come up with a method that can filter PHP results for listing items using JS. Look at these examples: http://www.autotrader.co.uk/search/used/cars/ ...
0
votes
2answers
53 views

Changing CSS classes when different strings are displayed in a text element with jQuery [closed]

I'm just wondering if this method would be possible using jQuery HTML and PHP. Basically I have a filtering system were products are listed, some have different attribute values such as Hatchback for ...
0
votes
0answers
163 views

What is the use of the prefix “for(;;);” in an Ajax response

After using the chrome debugger to inspect the ajax requests of Facebook (for curiosity), I noticed that the response is in JSON, however it is always prefixed with for(;;); In example, if the JSON ...
0
votes
0answers
54 views

How to bring an application from Sublime Text to a web IDE for sharing? [closed]

I generally work on my projects locally in Sublime Text but sometimes need to share them with others using things like Jsfiddle, codepen, or plunker. This is usually so I can get unstuck. Is there an ...
2
votes
1answer
155 views

Is this JS code a good way for defining class with private methods?

I was recently browsing a open source JavaScript project. The project is a straight port from another project in C language. It mostly use static methods, packed together in classes. Most classes are ...
0
votes
1answer
74 views

Falsey values vs null, undefned, or empty string

I've worked with jQuery over the years. However, recently, I've found myself getting deeper into the JavaScript language. Recently, I've heard about "truthy" and falsey values. However, I don't fully ...
1
vote
0answers
68 views

JS closures - Passing a function to a child, how should the shared object be accessed

I have a design and am wondering what the appropriate way to access variables is. I'll demonstrate with this example since I can't seem to describe it better than the title. Term is an object ...
0
votes
0answers
6 views

Using Twitter share and Facebook share [migrated]

Hi I m trying to use Social Plugins in my website For a Tweet on Twitter <a id="twitter-link" href="https://twitter.com/share" class="twitter-share-button" data-lang="en" ...
2
votes
1answer
88 views

Uniform variable naming across HTML, CSS and JS

I'm sorry if this is opinion based, but how do you guys make sure that HTML, CSS and JS have uniform variable naming? I use vim, but I don't know if IDEs are smart enough to do this on their own. In ...
-1
votes
0answers
12 views

Knockout custom text binding handler [migrated]

I created this custom binding handler : ko.bindingHandlers.line = { update: function (element, valueAccessor, allBindings) { // First get the latest data that we're bound to var ...
4
votes
1answer
82 views

JS design pattern/algorithm for avoiding duplicate redraws in a fairly coupled system

Given: some sort of widget based web app lots of JS functionality high coupling (communication/callbacks between widgets) widgets draw themselves certain widgets need to do a complete and fairly ...
0
votes
2answers
127 views

Old Browsers and Polyfills

Polyfilling, when is it too much? I've summed up this question into one sentance. Is it practical to polyfill all of the IE8 deficiencies with one solid javascript file, as in, would there be any ...
0
votes
1answer
58 views

Ideal & idomatic javascript interface for RESTful API

I am trying to write an angular service to interface with a RESTful API. For sake of simplicity, lets assume the API is + Company |___+ Department | |____ Person | |____ Person Notice how ...
3
votes
0answers
79 views

Are promises suitable for Model Controller communication?

I have an Express app built with the Yeoman Angular fullstack generator to build an API to send JSON to Angular. I'm trying to work out the best way to pass back information from my model to my ...
28
votes
8answers
5k views

Is splitting up a function into several inner functions an anti-pattern? [duplicate]

Imagine a long and complicated process, which is started by calling function foo(). There are several consecutive steps in this process, each of them depending on result of the previous step. The ...
0
votes
4answers
166 views

Is client side JavaScript capable of replicating the Node.JS module loading system?

I like the Node.JS style of JavaScript, where I can write all of my functionalities into smaller files and then require those neatly from within my code. I'm even thinking about trying to write a ...
9
votes
4answers
482 views

Should I parse XML on the server or provide a proxy and let the browser parse it?

I need to interface with a 3rd party API. With this API I make a GET request from within the end user's browser and receive an XML response. This data is to be used in a browser based application ...
2
votes
2answers
134 views

How are some IEEE 754 floats printed succinctly?

Using this calculator, I can see how the decimal ".8" and the expression ".7 + .1" have different representations: .8 = 1.1001100110011001100110011001100110011001100110011010 *2-1 .7 + .1 = ...
0
votes
2answers
99 views

Confused about javascript module pattern implementation

I have a class written on a project I'm working on that I've been told is using the module pattern, but it's doing things a little differently than the examples I've seen. It basically takes this ...
19
votes
6answers
1k views

Should I place functions that are only used in one other function, within that function?

Specifically, I'm writing in JavaScript. Let's say my primary function is Function A. If Function A makes several calls to Function B, but Function B is not used anywhere else, then should I just ...
0
votes
2answers
154 views

Should the check correctness of a time constrained puzzle game application be done on the server side?

I am working on an application where a user has to complete a puzzle and check within a given time limit. This is an HTML5 based game, I can't keep the solution on the client side. but I also want ...
-1
votes
0answers
33 views

Formatting issue on IntelliJ IDEA 13.0 [migrated]

I've ran into quite a bug in IntelliJ Idea 13.0 and I was wondering if anyone had experienced a similar outcome. Whenever we check in our builds, autoformat is set to true and this will reformat all ...
0
votes
2answers
109 views

Alternatives to the use of the Id/Name properties with non-inputs elements in HTML

I'm migrating a website that use Javacsript/HTML/PHP using reusable javascript code, in certain moment I saw the opportunity to simplify code in functions that use almost the same code. Let's say: I ...
-3
votes
1answer
297 views

Why is the JavaScript-language different in different programs/sites? [closed]

I'm kind of new to programming and i have a question that's been bothering me for awhile. Why is the JavaScript-language different in different programs/sites. I've used Codecademy to practice and ...
0
votes
1answer
96 views

Would it be the right software engineering system to move from AngularJS-based to jQuery-based or hybrid implementation for webapp?

I am presently working on an AngularJS-based chat webapp, and it polls the server for updates, and then renders them in what is pretty much a straight shot in AngularJS. The result looks appropriate ...
3
votes
2answers
200 views

What is the reasoning behind these design choices? [closed]

In ReactJS tutorial you are guided in the building of a commenting system. It's a very useful tutorial to understand ReactJS library, but there are some design choices I can't fully understand. So ...
-1
votes
0answers
19 views

Server-Driven Web Development [duplicate]

I came across the heading - "Server-Driven Web Development Considered Harmful" while reading the book Client-Server Web Apps with JavaScript and Java by OReily. Under this heading a line says, In ...
3
votes
1answer
117 views

A question about static types

How would you statically type the following JavaScript program function c(str) { c = eval(str); return c(str); } I'm not trying to start a flame war but I'm genuinely curious. I've always ...
0
votes
0answers
65 views

Using Number() vs. parseInt() to do type conversion? Which should I use when? [migrated]

For type conversion, when should one use the primitive wrapper Number() and when should one use parseInt()? I'm aware that parseInt() allows you to specify a radix, will truncate decimals so that ...
0
votes
1answer
127 views

How to tell node.js which javascript code runs on server vs client?

I am trying to learn the theory of node.js but can't seem to figure out how node.js knows whether to pre process it on the server or send it to browser for execution.
3
votes
0answers
34 views

Do I understand this Function.prototype.call() code correctly? [migrated]

The code: var content = Array.prototype.map.call(document.getElementsByTagName("p"), function(e) { return e.innerHTML; }); It's from p. 367 of JavaScript: The Definitive Guide, 6th ed. Here's ...
45
votes
8answers
6k views

Client-side coding: How to prevent malicious use?

Over the last few years, the trend for client-side (browser) applications has really taken off. For my latest project, I have decided to try and move with the times and write a client-side ...
2
votes
1answer
236 views

JavaScript Compression and Caching of Assets

I'm working on an idea that i can't seem to find a good answer though hours and hours of searching, I'm planning a small Canvas/WebGL Application this application will be using WebSockets to talk to ...
2
votes
0answers
83 views

JavaScript Combination Inheritance Pattern

In the chapter of Professional JavaScript for Web Developers on OOP, Nicholas Zachas describes a JavaScript inheritance pattern which he refers to as combination inheritance. The basic idea is that ...
0
votes
0answers
48 views

Token based autorization for a web game

I am lead developer for a multiplayer game in a small startup company. I would like to present here my solution for token based authentication and hear your opinions about possible weak spots. I am ...