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

Reason why client-side JavaScript does not allow access to POST/PUT/etc contents

Is there any theoretical reason why client-side JavaScript could not be spec'd to allow for direct access to POST or PUT contents without need for a server language to write it into client-side ...
0
votes
2answers
85 views

Will ES6 promises replace libraries like Q and Bluebird? [on hold]

How do built-in ES6 promises compare to existing userland promise libraries? Will there be advantages to using the new built in ES6 promises over established libraries like Bluebird? Will promise ...
0
votes
1answer
36 views

Choose approaches for updating an object

Say I have a simple object created by from user input: var input = { url: 'http://example.com/', path: 'abc', user: 'adam' }; And I am to write function(s) that update url and path properties ...
-2
votes
0answers
27 views

about 2d game, side-scroller, in unity engine [on hold]

after importing the character asset, when i press on the FPSinputcontroller in the inspector window, which should take me to the code sheet with colored lines , an error window appear, declaring an ...
1
vote
1answer
156 views

Using streams to connect programming languages

I'm trying to run a computation-heavy program that creates an image on a website. Is it possible to compute in C++ and have an output stream that connects to an input stream in Node.js to display an ...
0
votes
0answers
30 views

Login Tokens Remote DataServer for use in a Javascript/HTML-PHP environment

I've asked this question on stackoverflow, but i think this is a more appropriate place for it. I'm creating an app for iOS, Android and the Web. I created a separate Restful Data Service that is ...
0
votes
0answers
38 views

What's the Difference with these Knockout Viewmodel constructors?

When creating a viewmodel for Knockout, what's the difference here? I see these different implementations and I've tried a few and some don't work the same. //the most common example. function ...
-2
votes
0answers
52 views

how do i use opengl with nodejs ps i only know javascript [closed]

I do know about web-gl but would like to know how i could use open-gl for desktops because this program will be an offline implementation of a game/graphics engine with the open-gl library i have ...
2
votes
3answers
553 views

Why is it a good practice to keep Javascript code in separate files?

In web development we are commonly used to keep Javascript code in separate files, but sometimes we need this Javascript code to manipulate server side data locally. For example, making an Ajax Call ...
-1
votes
1answer
45 views

Should I switch to a MVC framework? [closed]

I've created a real-time single-page game that uses Node.Js and sockets. Almost every second, I'm updating 20+ span with jQuery in user's browser. I already wrote a few thousand code in client side ...
1
vote
1answer
107 views

What are the benefits of using new over closures

I've been programming in JS for over a year now, mainly in angularJS. And I can honestly say I've never made a function use prototypical inheritance. When ever i need a class like object that has ...
2
votes
2answers
342 views

should I test this public method

I have the following simple implementation: var VALIDATION_TYPES = { ERROR: 1, WARNING: 2 }; var validationRules = {}; this.addErrorRule = function (event, rule) { ...
0
votes
0answers
3 views

cannot set project's JavaScript Build Path in PHP- eclipse [migrated]

Completely new to eclipse-PHP-javascript. I have created a php project in eclipse and trying to set up the javascript Build Path after enabling javascript support for the project The problem arises ...
-1
votes
0answers
25 views

how do I convert a image to it's rgba values to write to a canvas? [migrated]

I wrote a utility to convert text to colors and back on a canvas(This Part works great.) The code which inverts and grayscales a canvas is the issue.If I use drawImage on the canvas and try to call ...
-2
votes
0answers
48 views

Embed a virtual oscilloscope in HTML5 web page? [closed]

Can languages other than javascript be used to make interactive elements on the html5 web page? I envision an online learning environment with highly interactive simulations (such as an oscilloscope) ...
13
votes
7answers
2k views

Is there a pattern for a more “natural” way of adding items to collections? [on hold]

I think the most common way of adding something to a collection is to use some kind of Add method that a collection provides: class Item {} var items = new List<Item>(); items.Add(new ...
0
votes
0answers
17 views

What is an efficient method for retrieving a column from a 1D array? [migrated]

An example in any language would help, though in the end I am going to be using either Ruby or JavaScript/CoffeeScript. Basically, I have a 1D array of pixel values. For example, I have an array ...
0
votes
0answers
23 views

Performance increase by only attach onblur handler inside of onfocus handler?

Given a web page with input fields, does it have a performance difference whether or not you assign the onblur handler inside of the onfocus handler like so: var inputFields = ...
0
votes
2answers
141 views

What is the best way to create dynamically a DOM?

I know that there are plenty answers to this question on stackoverflow, but I can´t find one that give me an answer that can help me to solve a question that came out after read a lot of Javascript, ...
-3
votes
2answers
98 views

How to convert a number into sum of numbers of specific length

I am trying to convert a number(x) into array of numbers so that their sum is equal to the number (x), but the array length should be equal to the given length. var x = 12 length 1: [12] = ...
2
votes
0answers
142 views

Is obtrusive javascript required to support a feature of angular.js?

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

How should I structure an application containing business logic and display?

I'm working on a simple board game that will run in the browser. I'm thinking how to structure the program and I'd like to hear your opinions. The program will consist of the user interface part (the ...
0
votes
0answers
119 views

JavaScript program design: to what degree should I separate logic and display?

Consider you wanting to implement a simple game of checkers. There would be a rectangular game board and the player would able to move the pieces around according to a particular set of rules. ...
0
votes
4answers
228 views

Identifying user of a webapp

For a small webapp I want to be able to identify a user. The issue is, if the user cheats in some manner, I want to be able to forbid him the usage of my application. I already have done extensive ...
2
votes
1answer
91 views

Why do browsers clamp timeouts and intervals?

I've been working on some abstractions of setTimeout and setInterval in order to process large sets of data without blocking the event loop in the browser. Upon this, I have discovered that browsers ...
0
votes
3answers
181 views

Online code editors programming language

When searching for online code editors (out of interest how all the course sites such as Codecademy has been made) I noticed they are all been written in JavaScript. Why are all those code editors ...
0
votes
0answers
15 views

Why does JSF not tend to render specific value to constant in some tags

This question is about JSF concepts or architecture; probably I don't understand enough to be more specific. There are some ways to pass parameters to commandLink actionListener. But there are no ...
1
vote
2answers
349 views

Is it possible to protect client side algorithms 100%?

If you had a pretty novel idea that involved a new algorithm. Like lets say you were the first person to think of orbitz.com or kayak.com (travel sites) and you were able to and wanted to implement ...
213
votes
7answers
17k views

Does using == in JavaScript ever make sense?

In JavaScript, the Good Parts, Douglas Crockford wrote: JavaScript has two sets of equality operators: === and !==, and their evil twins == and !=. The good ones work the way you would expect. ...
3
votes
2answers
60 views

Is it reasonable to have grunt/gulp build phases in javascript dev environment

Nowdays it's goes to be very fancy to have grunt/gulp build phases who concatenate and minify and organize javascript code. And I agree that this is important for production. But as a developer, I ...
-4
votes
2answers
54 views

Converting Web Apps to Smartphone Apps [closed]

Suppose I have an open source web app like this one (it's an IRC web chat client written entirely in javascript). Would it generally be an easy process to convert this into an iOS/android app without ...
-1
votes
0answers
15 views

Drawing a bisecting diagonal line in canvas? [migrated]

http://jsfiddle.net/skq3qfze/ HTML: (canvas class="col-md-1 myCanvas")(/canvas) CSS: .myCanvas { height: 400px; width: 400px; border: 1px solid black; } JavaScript: ...
0
votes
1answer
86 views

Do I need Bower for front end dependencies when I am already using composer?

I use composer for PHP dependencies. I was under the impression that for front end dependencies I should use Bower. So, I installed Bower and loaded my FE dependencies (Bootstrap, jQuery) using that. ...
1
vote
0answers
64 views

Traverse nested maps / objects from keys in an array

I think a code sample is going to work a lot better than my vocabulary: var keys = ['folder','name']; var data = { folder: { name: 'Special Folder' } }; Given the two vars above, I'm looking for a ...
3
votes
1answer
90 views

What is the correct way to publish a runtime? Should it be a singleton?

I have a compiler for a programming language that targets JavaScript. That language needs some global functions such as: alloc, memcpy, write and so on. My question is: where should I position those ...
0
votes
1answer
35 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 ...
1
vote
1answer
114 views

Relatively large data on client side in web application

We are discussing on building a web application where (as per clients requirement), there will be relatively large data (60,000 items) to be shown as tree view. Let's assume each item is string of ...
-3
votes
0answers
72 views

How to protect a private REST API in an javascript web application

I'm building a web application. It's basically a blog. There is a javascript client web application and there is a server that implements REST API. When user visits my blog, I use javascript ...
3
votes
1answer
104 views

How do I create a modal service with AngularJS?

I'm trying to make a service that's polymorphic based upon what mode is specified in the URL. If the char param in the route is set to 'p', I want to use a PresentMode service. If the char param is ...
1
vote
1answer
59 views

jQuery event binding management

Given the following elements: <div class="container"> <span class="some-class">content</span> ..n span repetitions.. </div> Given the following .on() ...
0
votes
1answer
44 views

MVC: Inserting a view from a SubController to its Parent controller

I have 2 controllers: 1 top level controller,MainController, and a SubController, which MainController has an instance of and controls. The SubController has a Subview which goes inside the MainView ...
3
votes
5answers
197 views

How do you unit test a function that clears properties?

I have a very common function that I have always unit tested in the same way, but I'm wondering if there is a better solution or if it's even possible a code smell is involved. It seems like a very ...
1
vote
1answer
147 views

The Better Parts and Delegation: Is Crockford Too Extreme?

Douglas Crockford has recently been giving a talk called The Better Parts. The gist of the talk is that JavaScript developers should actually avoid a superset of the The Bad Parts, which now includes ...
3
votes
4answers
270 views

What programming mindset to have towards JavaScript? [duplicate]

I used to program in Java. As a result of that I got well-versed with Object Oriented Paradigm. In my opinion it is a great approach to programming because it's easy to unit test, use design patterns, ...
1
vote
1answer
41 views

Is having a parent controller to manage a set of tabbed sections an anti-pattern for an angular application?

A lot of times, I have long forms that I divide into multiple tabbed sections. Each section is managed by it's own controller and there is a parent controller that manages the whole view. I use ...
2
votes
1answer
85 views

AJAX - What exactly does that encompass?

So I see on a lot of people's resumes they list AJAX in their technologies (or programming languages - and I recognize that it is not a language). To me, AJAX seems like such a small concept to be ...
1
vote
1answer
26 views

Compose nested EventEmitters elegantly

I am developing a server-side JavaScript tool, and trying to do so in a modular way. I have a Parser class that is an EventEmitter - you call parse and it will eventually emit data and end events. It ...
4
votes
1answer
123 views

(jQuery) What is wrong with methods such as .append?

tl;dr: What is wrong with the efficiency of methods such as .append() and what can be alternatives to this? Explanation: Hello everyone. I occasionally have to build A/B tests for websites, which ...
0
votes
2answers
94 views

Porting an algorithm implementation licensed under GNU GPL v3

I'm working on a JavaScript port of a red-black tree implementation in Java from the book Algorithms 4th Edition, by Sedgewick and Wayne. I believe that my JavaScript port qualifies as a derivative ...
3
votes
3answers
188 views

Easy way to make old javascript files conform to new quoting standard?

We've just started putting linting in place at my workplace, and a lot of the devs didn't realize our standards called for double-quotes everywhere. About 50% of the codebase uses single-quotes, so ...