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)

9
votes
6answers
2k views

Can JavaScript be used as a general scripting language?

I've used JavaScript and some frameworks (jQuery, Prototype, some node.js) for client-side web programming, but never on the desktop, where I do most of my scripting work in either Python or Bash. ...
41
votes
6answers
10k views

What are the pros and cons of Coffeescript? [closed]

Of course one big pro is the amount of syntactic sugar leading to shorter code in a lot of cases. On http://jashkenas.github.com/coffee-script/ there are impressive examples. On the other hand I have ...
143
votes
3answers
40k views

Pros and Cons of Facebook's React vs. Web Components (Polymer)

What are the main benefits of Facebook's React over the upcoming Web Components spec and vice versa (or perhaps a more apples-to-apples comparison would be to Google's Polymer library)? According to ...
2
votes
3answers
556 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 ...
0
votes
1answer
321 views

Dynamic query in Mysql

I'm doing a J2EE web application with Struts2, Mybatis and a MySQL database, so what I want to allow to the user is to be free to choose different parameters to perform a select to a table in the ...
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
37 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 ...
0
votes
0answers
52 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 ...
5
votes
1answer
1k views

Building a Graph Editor - How to create a data driven graph

I am developing a graph-editor that uses drag and drop to build hierarchical graphs (containing nodes and links). Each node in the graph should be linked to a table in our database (SQL Server). I did ...
1
vote
1answer
258 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 ...
-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 ...
-2
votes
0answers
53 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 ...
1
vote
1answer
158 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 ...
1
vote
1answer
197 views

Methods for structuring JavaScript SDKs

I've built a REST API and have been using Backbone models throughout a couple different applications to communicate to it. I would really like to build a single JS SDK that can be used in any ...
1
vote
3answers
272 views

XSLT equivalent for JSON

I was interested in finding (or if necessary developing) an XSLT equivalent for JSON. As I have not found any, I was considering the possible query language to use for matching JSON paths so as to ...
-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) { ...
6
votes
2answers
9k views

How to run C++ code in browser using asm.js?

An asm.js application is very fast (near native C++ speed): http://kripken.github.io/mloc_emscripten_talk/micro4b.png But how is it possible to write one in C++, convert it to LLVM code, then do ...
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 ...
13
votes
7answers
2k views

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

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 ...
1
vote
2answers
157 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
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
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, ...
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 = ...
2
votes
1answer
262 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
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 ...
9
votes
3answers
2k views

Are there open-source JavaScript libraries addressing multiple browser tabs and client state for newer browsers? [closed]

There are a few new HTML5 features that have made it into recent browsers that allow sharing state among tabs, browser windows, same domain windows, etc. So it's probably gotten a little easier to ...
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
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] = ...
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() ...
2
votes
0answers
143 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: ...
22
votes
8answers
18k views

Why almost no webpages hash passwords in the client before submitting (and hashing them again on the server), as to “protect” against password reuse?

Relevant XKCD There are many sites on the Internet that require login information, and the only way to protect against password reusing is the "promise" that the passwords are hashed on the server, ...
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
121 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
0answers
16 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 ...
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 ...
14
votes
7answers
4k views

Would Python be too slow for client-side use in Browsers?

I've heard the statement that Python would be too slow to be of any use in browsers. I reckon Javascript is only superior in this aspect because of companies like Google who need it fast (and made it ...
0
votes
3answers
182 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 ...
3
votes
2answers
315 views

How do I integrate a browser-based JavaScript unit testing framework into my workflow?

I'm wondering how I seamlessly include a JavaScript unit testing framework into my workflow. The context is, we have an existing data processing algorithm + webapp to display it, with no automated ...
1
vote
2answers
350 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 ...
3
votes
3answers
3k views

How do I prevent useless content load on the page in responsive design?

In responsive design, elements are hidden in the page with @media queries and display: none in CSS. Ok. In my design however browsers that have less than 800px in width should avoid loading some ...
0
votes
1answer
141 views

Creating a voting platform for submissions during timeperiod

I have a site where stories are submitted at any time by users. The staff would like the ability to create a voting period at any time. For example, they can choose to open up voting from today until ...
-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 ...
3
votes
2answers
61 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 ...
-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: ...
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 ...