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)

-3
votes
0answers
39 views

Will ES6 replace CommonJS/AMD? [on hold]

This is a fairly simple question, but I can't find an direct answer. ES6 is going to be the standard for JS and soon enough the new design for module loading will be in conflict with ...
-1
votes
0answers
99 views

Sending home JavaScript errors for later analysis

I had the idea of sending home the details of a JS error in case they should occur. For this I thought subscribing to window.onerror event would be a good place to start. Add some simple code to ...
0
votes
2answers
66 views

What is the normative (best) use of Javascript arguments object [on hold]

JS offers the 'arguments' object inside of functions to represent all passed arguments. Is there any broadly accepted concept for when/where this should be used? I've seen items like this in the ...
-1
votes
1answer
160 views

Is class with callbacks a code smell in JavaScript?

When writing JavaScript (especially in node.js), I tend to use plain functions and callbacks. However, sometimes there's some context to share between some functions and I don't like to pass this ...
-5
votes
0answers
28 views

Annoying white background in html [on hold]

So I put an image into my site using the tag, but the thing is I set a background image using css, and now the image I inserted has this ugly white background that covers my background. If anyone ...
-1
votes
0answers
76 views

What is the best way to manage (limit?) memory usage in Javascript? [on hold]

Back in time when I had to allocate and deallocate each byte in my software, I had a good picture of memory usage in my mind. But now I am always uncertain. All those cross and circular references, ...
-7
votes
0answers
50 views

As a newbie web developer, should I start learning ES6 straight away and skip “old” javascript? [closed]

First of all I am newbie in the area of front-end web development so my questions and thoughts might sound naive to experienced guys. My background is .NET/C#/WPF for 5+ years but I started getting ...
-4
votes
0answers
18 views

converting image to rgb string [closed]

I am making a movie in Khanacdemy processingJS, and am trying to decode an image. I have an array for my image where each color is assigned a number. how can I convert an image to this string of ...
1
vote
0answers
78 views

How to tell that a Javascript code already needs AMD (RequireJS, …)?

At some point code is complicated less if you introduce a new abstract than if you continue as it was. Some trigger should fire in a head of a programmer. Like, I was coding fine, but now I've added ...
-5
votes
0answers
80 views

Need Framework idea [closed]

I have much experiences with PHP, Javascript and CSS. I have coded much things in these two languages, but I want to code a Framework in one of these languages. Any of you guys have an idea what you ...
0
votes
0answers
24 views

Why can't I use parens when executing function in return object? [migrated]

Can someone explain why, if I add parens to _start in the return statement I get the error: undefined is not a function _start is function, is it not? .factory('TrackPage', ['$location', ...
-4
votes
0answers
29 views

Sync code after compressing and uploading [closed]

I have made an android app using javascript and phonegap. Now when its final and i want to upload it on play store, i want to compress its code to reduce its size. Now as my code is synced to github, ...
-2
votes
0answers
18 views

hide url param cakephp with refresh [migrated]

how do you hide / unhide / mask URL query parameters in cakephp? I've tried with javascript but still error when I tried the following pages of his. http://www.mywebsite.com/web/index/page:2?url=web ...
0
votes
2answers
128 views

What are the tecnhical reasons for email HTML, CSS, Javascript limitations and their persistance [closed]

If you've ever made a custom email you'll know that there are significant limitations in you need to be aware of. The most obvious limitations being: No support for Javascript in emails No support ...
0
votes
1answer
92 views

Declaring many times: script type=“text/javascript”

Trying to clear my HTML code, is it correct if in my web page I declare many blocks of <script> . Like this: <script type="text/javascript"> ... ... </script> <script ...
0
votes
0answers
40 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 ...
0
votes
0answers
55 views

Using Singletons in JS with workers

I'm building a javascript application that does continuous drawing, but relies on asynchronous scripts in the background which also need to poll for events and write to "global variables". This got me ...
4
votes
2answers
163 views

Dealing with browser cache in single-page apps

I'm trying to figure out how to properly handle the web browser cache for single page apps. I have a fairly typical design: several HTML, JS and CSS files implementing the SPA, and a bunch of JSON ...
0
votes
0answers
38 views

Scale parts of image to fill bezier path with no wastage

I want to be able to take an image and stretch/contract each pixel row (or 5 rows for performance) to fit within a curved shape. I've been searching for this for the last few days and have turned up ...
0
votes
0answers
99 views

How to code a function to be used with or without callback on Javascript? [migrated]

I'm wondering how (if possible) I can create the same function, with exactly the same functionality, but to be used with a callback or without it. Here is an example with the "wanted effect" that is ...
-2
votes
0answers
20 views

How do you make the node_modules folder read/write in WebStorm [migrated]

I'm using WebStorm on a Node.js project and want to edit the files in the node_modules folder but WebStorm won't allow this. I found the padlock at the bottom right on the IDE but switching that ...
1
vote
0answers
158 views

Client side web application architecture - best practice & patterns [duplicate]

I'm inheriting some code that takes a rather different approach to architecture than I'd have chosen myself. It consists of a HTML page, some javascript library imports and a single DIV tag. This ...
-1
votes
1answer
85 views

Is there a way to run javascript on a present webpage [closed]

I don't have programming background. I have started learning javascript recently. I'm wondering if there is a way to run javascript on a webpage ? for example I would like to write a javascript on ...
0
votes
1answer
75 views

How to lock/unlock a button based on tweeting

I have a button that will be disabled until you send out a tweet that I have crafted. Only users with twitter accounts will have access to this, and I will require users to sign-in to be able to ...
0
votes
1answer
54 views

Common techniques to integrate social media login to a website that requires account registration

I have developed websites where users would register with a username of their choice and an entry would be created in a database table that holds their username and some sort of salted password. They ...
0
votes
0answers
76 views

What does this javascript file do? Is this a virus? [migrated]

While searching on google I found a website that shows other content to Google Bot and other to his users, and also a very suspicious javascript file. Maybe it's a tracking cookies virus/malware, I ...
1
vote
0answers
99 views

How can I put multiple hierarchical forms in a single web page and avoid making it a mess?

We are a group of developers working on a web application that accepts forms filled and sent by our users and present it in an overall view. Our main form view looks like this: There are multiple ...
1
vote
1answer
52 views

Is doing Parent.call from the child object a right way to implement Inheritance in JavaScript?

I came across this piece of code it didnt look that right to me. Is it the right way to implement SUPER in javascript. if not what is the right way? function Person(name){ this.name = name; } ...
0
votes
2answers
106 views

In Node.js, are non-blocking constructs usually preferable to blocking ones?

Is the following a statement of best practices in Node.js with regard to web applications? If not, how could it be improved? The statement The lifecycle of any web app has at least two phases: a ...
1
vote
3answers
307 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
267 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 ...
1
vote
1answer
234 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
132 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
1answer
84 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
161 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 ...
0
votes
2answers
67 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
168 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 ...
2
votes
1answer
167 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 ...
1
vote
3answers
174 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
77 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 ...
2
votes
1answer
96 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 ...
4
votes
1answer
91 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
133 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
61 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
86 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
178 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
511 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
135 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
105 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 ...