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)

5
votes
1answer
952 views

How should I handle a redirect to an identity provider during a web api data request

Scenario I have a single-page web app consisting purely of html, css, and javascript. After initial load and during use, it updates various views with data from one or more RESTful apis via ajax ...
7
votes
1answer
346 views

Language compiled to JS – most elegant way to do synchronous-style waits

I'm trying to make (yet another) language that compiles to JavaScript. One of the features I'd like to have is the ability to perform JavaScript's async operations synchronously (not exactly ...
27
votes
6answers
4k views

Dynamic Code Evaluation in Java - Clever or Sloppy?

I am trying to create a flexible ACL framework in Java for my application. Many ACL frameworks are built on a whitelist of rules, where a rule is in the form of owner:action:resource. For example, ...
0
votes
3answers
291 views

Is JavaScript fail-safe?

I was compiling a list of comparison of top 10 programming languages (JavaScript included). I was doing it from this Wikipedia page. However, in the third table (Failsafe I/O), there is no row for ...
1
vote
1answer
97 views

Multiple CS Sheets or Javascript

I have a homepage with a navigationBar on top of the Viewport contains two buttons. One is the default selected home button which calls/displays home.html. The other for example is Ubuntu which calls ...
0
votes
0answers
36 views

best/preferred way to create a “plugin” in JavaScript: “OOO” or array of each instance [duplicate]

I'm working on creating a "plugin" in JavaScript. I can't think of how to simplify my plugin's purpose so for the sake of simplicity let's say it is a table filter plugin. Either way the user would ...
1
vote
3answers
198 views

Avoid opt(options) in javascript [closed]

A lot of frameworks, most like jQuery plugins uses the "optional" parameter. Basically a dictionary (or key/value structure) with a bunch of additional parameters instead of send in the parameter's ...
3
votes
6answers
4k views

Is it possible to half-way synchronize javascript functions that include async calls?

I am wondering if there exists a way to half way synchronize javascript functions, where data is requested on the fly. I don't want to make it purely blocking (which I guess is impossible), I just ...
1
vote
1answer
237 views

Best use of the React frontend framework

I've been using rails' erb template for my views, but I've recently been trying to incorporate React as my front end framework. I'm a little lost on how front end frameworks are supposed to be used. ...
3
votes
1answer
230 views

How can 'yield' be added as a keyword in ES6 if it wasn't a reserved word?

yield is not a reserved word in JavaScript, yet ES6 makes it a keyword. I thought the point of reserved words was for backwards compatibility. For example, let and const were reserved, so you ...
5
votes
3answers
699 views

How come javascript, being a prototype based language, doesn't have an easy way to access the prototype?

May be this is a stupid question, but I'm kind of intrigued. Being JavaScript a prototype based language, with its pseudo-class function constructors sort of half baked (remember JavaScript: The Good ...
0
votes
1answer
469 views

Dynamic query in MySQL

I'm doing a J2EE web application with Struts2, MyBatis and a MySQL database, so what I want is to allow the user to be free to choose different parameters to perform a select to a table in the ...
3
votes
2answers
187 views

Would there be any benefit to writing synchronous code using the syntax of promises

Is there such a concept as a synchronous promise? Would there be any benefit to writing synchronous code using the syntax of promises? try { foo(); bar(a, b); bam(); } catch(e) { ...
1
vote
5answers
470 views

why are globals bad in javascript [duplicate]

I've been writing web applications for a while now , and everyone knows the one golden rule not to assign variables to the window object , don't ever assign a variable without using var. My ...
1
vote
1answer
106 views

Checking for valid state inside function or outside [closed]

This is a common occurrence in programming and is language agnostic, you have a function that needs to do something but in only in some cases. Maybe it's a feature-toggle, maybe it's a function that ...
3
votes
3answers
960 views

Why is a click event triggered only after mouse click and release?

Every click event on the web works on mouse click and release. Is there a way to do a action on a click event before mouse release??
2
votes
0answers
65 views

Reasoning behind indexedDB versioning

So, the last 2 weeks I have been fighting with indexedDB and one of two recurring questions that keep popping up is why indexedDB has to use/present it's entire versioning system? I do understand that ...
2
votes
1answer
151 views

Are web sockets a browser feature or supplied by a specific OS version?

Are web sockets a web browser feature, developed and evolving as the browser developers want, or this feature dependent on the OS version? For example, can I use this feature in JavaScript in IE and ...
0
votes
1answer
392 views

How to create a JSON or HTML file that dynamically mirrors file directory structure for jsTree 3.0 [closed]

I am looking to create a JSON OR HTML file that will accurately give the folder/file structure for a directory for use with jsTree 3.0 (www.jstree.com). I want to make it AJAX/lazy load so that each ...
2
votes
2answers
135 views

How hidden classes allows faster access to properties in google's V8?

As Lars Bak and Jay Conrod described in several videos and papers, the main idea of hidden classes in V8 is to store concrete offset or transition to another hidden class which probably contains this ...
0
votes
0answers
127 views

Choosing a javascript framework for a massively multi-player game : React vs Ember 2 vs other better option

I'd like to add to my Ruby on Rails app a javascript front end using basically Rails a json api sending data to the front end. The question for me is: React or Ember 2 (or maybe another viable ...
1
vote
1answer
232 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 ...
0
votes
1answer
156 views

Do you also find the use of functional reactive programming in JavaScript a bit overbloated? [closed]

I've been reading this article: http://modernweb.com/2013/09/30/functional-reactive-programming-in-javascript/ and I found the examples there way too complicated for what the code is supposed to do. I ...
0
votes
1answer
81 views

Personal Digital Signatures in Web Applications [closed]

In order to sign data with personal digital signature in a web application, server side languages like PHP can do the whole job, but that would require that the user uploads his private key, lets say ...
6
votes
3answers
2k views

Javascript, Text Annotations and Ideas

I am very curious to hear input from others on a problem I've been contemplating for some time now. Essentially I would like to present a user with a text document and allow him/her to make ...
13
votes
7answers
2k views

What constitutes “improper use” of the javascript Eval feature?

Eval is a notoriously controversial language feature. Douglas Crockford flat out rejects it. I'm wondering what specific risks Eval brings about. According to this question, Improper use of eval ...
29
votes
14answers
9k views

What benefits are there to native JavaScript development? [closed]

Given how much simpler jQuery development is, when compared to native JavaScript, what makes people forgo libraries like jQuery altogether? Is this because jQuery has limitations or it is slow? I ...
14
votes
3answers
2k views

why is the latter function 10% faster although it must create the variables over and over again?

var toSizeString = (function() { var KB = 1024.0, MB = 1024 * KB, GB = 1024 * MB; return function(size) { var gbSize = size / GB, gbMod = size % GB, mbSize = gbMod ...
7
votes
5answers
800 views

Why JavaScript? What's the advantages? [closed]

This is not a simple question, but I was thinking, what advantages are really there in the JavaScript language? We all use JavaScript on the browser, of course, there is no other choice (you can use ...
0
votes
6answers
3k views

Mixing jQuery with JavaScript

I just asked this question at SO about some bugginess I am experiencing with jQuery and IE8, and someone commented that he was appalled that I would mix JavaScript with jQuery (he has since deleted ...
0
votes
1answer
142 views

Does streaming video pass through the website's server when embedded with javascript from another site?

Not sure how else to phrase this question, so my apologies if it's been asked before. We use Brightcove for streaming video. They offer an option to embed one of their players on your webpage using ...
-1
votes
1answer
60 views

keeping of all javascript functions in one place [duplicate]

In php website I am using different javascript functions in different pages for example page a calls functions 1,2,3 and page b calls functions 2, 4, 6 and page c calls functions 3, 6 can I place ...
1
vote
1answer
159 views

Calculating winning probability for 2 teams using their history?

So I'm working on this project where I have a database full of team winning history. For example let's say these are all football teams. Every match has 2 participants (2 teams) and always a winner. ...
0
votes
2answers
209 views

Is there any plan to take out “features” from next versions of javascript? [closed]

I'm looking to learn javascript (now for real) and I've had a look on the latest version of ES6 which is supposed to be frozen in terms of features set. It seems to be the pretty much same as ES5 ...
-3
votes
1answer
405 views

Why doesn't v8 compile typescript instead of javascript? [closed]

Since Typescript is just a superset of javascript (every javascript program is also a typescript program), I've got this idea - why doesn't v8 support typescript? or anything statically typed ...
2
votes
1answer
103 views

Need an algorithm to filter this collection format

I'm sorry the title is so vague ... I cannot think how to describe it any better. I have a collection in this format: var myCollection = [{id:"a"}, {id:"b",excludes:["a"]}, {id:"c",excludes:["b"]}]; ...
0
votes
0answers
54 views

Extension of native prototypes, good or bad practice? [duplicate]

Today I stumbled upon this page on the Mozilla Developer Network. In it, not only it is stated that it's a bad practice to extend native prototypes, but also that there is only one exception to this, ...
2
votes
1answer
185 views

Uniform identifier/class naming across HTML, CSS and JS

How does one ensure that HTML, CSS and JS have uniform identifiers. For example, one such set of identifiers could be class names. e.g.: CSS: .user-profile{ ... } JS: ...
0
votes
1answer
183 views

Best Data structure for implementation of dependent drop-downs

I want to implement dependent drop-down feature on a web page in my website containing the following drop-downs: User's group name Group events (dependent drop-down) Locations (dependent drop-down) ...
1
vote
1answer
253 views

How to merge two functions that do same things with different variables

I have these two Javascript functions that are equal except for the variables onClickVoteUp: function (e) { var $target = $(e.target); var upvoted = this.model.get("upvoted"); var ...
5
votes
1answer
158 views

Is it poor decision making that using promises for GUI inputs?

So as you know the context: DOM with JavaScript, even though I think it is mostly a language agnostic issue (I know I put both language-agnostic and JavaScript tags, but it's only to let you see ...
3
votes
3answers
194 views

Anything wrong with direct evaluation of JSON if your own code created it?

Suppose I have a server-side variable containing JSON (named strJSON) that my own code created. In JavaScript I can consume it like this: var data = <%= strJSON %>; or use a JSON parsing ...
1
vote
1answer
277 views

Assigning default values from environment variable in Node.js

When attempting to set default values for parameters that may exist in environment variables in JavaScript, I often see this pattern: var lag; try { lag = process.env.THROTTLE_LAG; } catch ( e ) ...
1
vote
2answers
133 views

Observer pattern: Prevent multiple firings on changed internal property

I have an object Foo that has 2 public properties: A and B. These properties can be changed from outside, as the application I'm working on is using a data-binding architecture. This is the ...
2
votes
1answer
146 views

Declaring JS Functions in Two Ways : What's the Benefit?

I've come across JS code in which I see functions being declared in two different styles: Method 1 function doSomething(){ alert('This is one way of declaring a function'); } Method 2 ...
25
votes
1answer
7k views

Why should I use Bower? [closed]

I can fully appreciate the benefits of a package manager like Python's pip, Node's npm, or Ruby Gems since they're doing much more than adding files to your applications path. Maybe I'm missing the ...
1
vote
0answers
195 views

Preserving Pre-formatted Multi-Line Strings in Node.js Scripts

There is a lot I don't like about PHP, but one thing I love is multi-line strings: $query = <<<EOT select field1 ,field2 ,field3 from tableName where field1 = 123 EOT; ...
26
votes
2answers
2k views

Is there any reason to use the “var” keyword in ES6?

Babel's guide to ES6 says: let is the new var. Apparently the only difference is that var gets scoped to the current function, while let gets scoped to the current block. There are some good ...
-2
votes
6answers
4k views

How can I team up two MVC frameworks without having them fight each other? [closed]

I'm creating a CRUD-based web project, and am thinking about using a server side MVC framework (such as CodeIgniter or Laravel) in tandem with a client side MVC framework (such as AngularJS). Is this ...
0
votes
1answer
114 views

Should there only be one controller per page within a JavaScript-based MVC architecture?

Let's say that I create a page in my marketplace web application where buyers can see a catalog of all products offered by some or all sellers or sellers can see just their own products in a preview ...