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)

1
vote
1answer
159 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 ...
24
votes
1answer
98k 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 ...
-2
votes
0answers
12 views

Accessing Dynamically create div via js [on hold]

I have created a tiny little script to fetch data from a json database, then insert said data into dynamically created divs in the browser. Only when i search for them using ...
0
votes
0answers
36 views

Why was `Array.contains` renamed to `includes` if MooTools issue seems trivially resolvable?

I find it a bit hard to follow the mailing list discussion, so I'm asking here. The way I understand it, the original problem with Array.contains was that MooTools was assigning it, and then ...
0
votes
0answers
30 views

web requesting - time competition - javascript? [on hold]

first of all, I would like you to excuse my english and description of the problem. I am not english native speaking, so I am trying my best.... Before you say, that is am abusing some server- I need ...
0
votes
1answer
47 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
votes
0answers
7 views

Using GreaseMonkey to change Javascript variable [migrated]

I've got a question regarding a website that I use quite frequently. The website is essentially a browser-based air traffic control simulator. The page uses a php script to load the JavaScript ...
5
votes
1answer
114 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
168 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
57 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
63 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
112 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 ...
21
votes
1answer
5k 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 ...
0
votes
0answers
25 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; ...
0
votes
1answer
355 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 ...
9
votes
2answers
212 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 ...
1
vote
1answer
313 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
6answers
3k 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 ...
-1
votes
0answers
52 views

Is it possible to manipulate mov files with js [closed]

I'd like especially to know if it is possible to join two .mov-files using js. If there is no build-in-function, is it possible to manipulate the .mov-files "binary". In the end the .mov-file has a ...
-1
votes
0answers
30 views

How to create “fuzzy” material design type shadows on a canvas? [migrated]

I can't seem to find out how shadows are created in material design, or how css does it. Specifically, I am curious how, if given a canvas, one would create the 'blur' part, using algorithms. Below is ...
-5
votes
0answers
32 views

why alert pop up when window on loading, not by click button? [closed]

<!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Work with Numbers</title> <script src="labJS.js"> </script> </head> ...
0
votes
1answer
97 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 ...
1
vote
1answer
218 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 ...
9
votes
11answers
6k views

Do I have to learn html and javascript to create web applications? [closed]

I am an experienced Java programmer, and I want to create a complex web application requiring dynamic pages, drawings, etc (take SO as an example). Do I have to learn javascript/html in order to ...
1
vote
1answer
176 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
0answers
25 views

Better pattern with promise code [migrated]

I'm programing server side node for a huge project. And I'm thinking my brains out about the best programming pattern that will be suitable for fast modification and changes. Tell me what you think ...
2
votes
0answers
34 views

Correct Approach to Refactoring to Promises [migrated]

I am in the process of refactoring some complex code that uses callbacks to instead use promises. I am trying to figure out if my proposed approaches make sense. I did not think this was a good ...
2
votes
3answers
143 views

With only backend development experience, how do I go into frontend development (js, html, css)? [closed]

Currently I am interning at a company as a "full stack" developer (Application developer on the job title) and I realize that I am having difficulties coping with frontend tasks. This is especially ...
2
votes
1answer
68 views

How to deal with server-side and client-side naming conventions that clash? [closed]

I have a project that uses the underscore naming convention for the MySQL database and PHP scripts but uses camelCase for the javascript application (a common scenario I'm sure). However, once JSON ...
0
votes
1answer
122 views

Better pattern than large if/else if/else for checking conditionals [duplicate]

I've got a fairly large set of booleans I'm checking in javascript, and then using them to alter the state of a layout in my React app. The whole thing is unwieldy, difficult to read, inelegant, and ...
16
votes
1answer
694 views

When to use prototypical programming in JavaScript

I've spent a good bit of time developing simple widgets for projects in the following way: var project = project || {}; (function() { project.elements = { prop1: val1, prop2: val2 } ...
3
votes
1answer
224 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 ...
2
votes
1answer
45 views

How Javascript Engines access/lookup property names?

How Javascript Engines access/lookup property names? what kind of associative array (data structure or search/lookup algorithm) did they use? (for V8, TraceMonkey, JSC, and Rhino) For example, in C++ ...
0
votes
1answer
115 views

Does react.js make sense for a static content-driven site?

I'm pretty sold on the react.js model because it makes DOM manipulation so smooth and comprehensible. But I'm wondering how it could be leveraged for a site that's largely static with big blocks of ...
1
vote
2answers
165 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 ...
2
votes
1answer
69 views

The meaning of 'fully traversable namespaces' in JavaScript

During research into architecture of single page applications, I came across the following resource by Mikito Takada, written around 2013: http://singlepageappbook.com/ In his introduction he ...
2
votes
0answers
119 views

Deleting all cached page of the site [migrated]

Scenario Mobile and desktop version. I'm developing a website with a desktop and a mobile version: users can choose to switch version if they want to: javascript will save a cookie telling the ...
2
votes
1answer
297 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
0answers
21 views

modelling an ecosystem evolving on a landscape

I would like to understand a bit more the theory and the approaches available in modelling a population roaming across a landscape. Assume discrete time and space as simple as a discrete grid and a ...
0
votes
0answers
39 views

How to profile and compare two client-side approaches? [closed]

I'm facing a project in which presumably large datasets will be interactively visualized client-side. These datasets' sizes vary, both in number of rows and number of columns. The visualizations and ...
0
votes
1answer
42 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 ...
5
votes
2answers
450 views

Where is the evidence for the performance of Node.js?

A lot of developers, especially ones who haven't used Node.js in production, seem to believe that Node.js is faster than other interpreted languages such as PHP, Python, and Ruby. These claims ...
0
votes
0answers
47 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 ...
-4
votes
0answers
21 views

PDF popup in Mozilla [migrated]

I have a PDF file generated through jsPDF. When the file opens in Mozilla, a popup windows appears as attached: I would like to put some meaningful description there instead of "blob". How can I do ...
0
votes
1answer
45 views

Incorporating web designer's into a rails app

I have a designer who has great knowledge of HTML, CSS and JavaScript (Not jQuery or AJAX though). He gives me his designs in those files and I have to incorporate it into my apps. The site is not ...
4
votes
1answer
141 views

Does HTML 5 undercut the need for a full-featured Javascript framework? [closed]

We're redesigning a website. Right now it uses Dojo, a large (and complex) Javascript framework. One person insists that we need Dojo because of things like (random examples) client-side ...
0
votes
1answer
68 views

Should I prefer classes or singletons in JavaScript/Node?

This question applies especially to Node.js, but also to JavaScript in general. I started working on a simple web app in Node.js. I'm relatively new to Node and JavaScript, and come mainly from C# ...
2
votes
1answer
127 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 ...
1
vote
2answers
68 views

How to make scalable modules in a div element

I'm interested in creating web modules that are encapsulated by a div element in a manner that, by simply resizing the div, everything in that div scales to the dimensions of that div proportionately ...
0
votes
1answer
158 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 ...