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
0answers
10 views

Nested website navigational menus

So, I have created a website that has a navigational menu made up of nested unordered list elements. For example, <ul> <li>Home <ul> <li>About Us</li> ...
0
votes
0answers
5 views

dynamic api code generation in nodejs

We are using nodejs and cassandra for backend stuff. In past few months we wrote same CRUD code for different apps. I am thinking of some way to automatically generating CRUD code. I came across ...
2
votes
1answer
79 views

What would be a reason not to embed JS in C?

I'm working on an opensource application that processes JSON in C, because I would like to make it easier for people to help me in the project and because JSON is so close to JS. I want to embed a JS ...
1
vote
1answer
54 views

Which JavaScript Template (jst) syntax uses double-brackets, (e.g. [[ and ]] )?

I'm looking at the source code for a Rails application that uses Backbone and there are template files with .jst.ejs extensions. The templates include HTML with lines of JavaScript wrapped in ...
-5
votes
0answers
26 views

copy and paste from text box to text box [on hold]

you can make a little program that copies the text of a text box on a web site?. I refer to the email address temporary guerrillamail. and to pass this argument to another text box to another website? ...
0
votes
0answers
40 views

JavaScript: How future-proof is using the onpaste event? [on hold]

I've been building a jQuery plugin which, along the way, required me to handle the user pasting a value into an <input> element. I've handled this by using the onpaste event. However, ...
0
votes
1answer
42 views

Is there a relationship between a data source (JSON) and the Model that consumes it?

I have put together a large quiz data structure. It is in JSON format but I guess it could be XML etc. It may look something like this simplified: { "quiz":{ "title": "Welcome to Quiz" ...
-2
votes
0answers
29 views

Angular service with different angular app [migrated]

Here i am using angular service.In my case i am getting value for first app but not for second .please help me . thank you. here is my html:- <div ng-app="mainApp" ...
0
votes
2answers
74 views

How can I show and hide a single field across my web application through a checked value?

Let's say I have a field called "FooName" and I have "FooName" in several places across my web application (ASP.NET MVC4). I have a check box that allows me to turn "FooName" on and off across the ...
-1
votes
0answers
5 views

D3 show segment of series data [migrated]

I'm looking for advice on how to tackle the following chart in D3.js: I have data in the following format for the 7 series shown Learning Disability AgeBand | Percentage 0-4 | 0.02 5-9 | ...
4
votes
1answer
178 views

Is localStorage under The Cookie Law?

I'd like to avoid having the cookies banner on my websites where possible. Could I store session id's in localStorage to bypass implementing the banner?
-7
votes
0answers
29 views

What editor should i use to code ,compile and execute a java script scripting language? [closed]

I have learnt C and C++ languages . Now I want to learn java script like we have turbo c or c language what software should i download to learn java script?
1
vote
1answer
45 views

Does requestAnimationFrame() really align with monitor refreshes?

Take this code: requestAnimationFrame(function (timestamp) { console.log('one', timestamp); }); requestAnimationFrame(function (timestamp) { console.log('two', timestamp); }); // logs: // ...
0
votes
0answers
68 views

Javascript: Scan webpage for links [closed]

Using JavaScript, I would like for a user to click on a button that prompts them to enter a URL. The URL entered is then scanned for links. The source link and links on the page are then placed in a ...
0
votes
1answer
216 views

Is writing code chronologically the best way for readability? [closed]

So I've been writing a lot of JavaScript lately. Despite what many people say I think JavaScript can be a simple and beautiful language. What I've pondered of late is how to structure the code so it ...
0
votes
0answers
54 views

Why does a lot of Angular source code avoid enclosing the contents of a file in a closure?

I am assuming because it is a standard practice in the Angular world that, any sort of module system has to be wrapped as an Angular module and angular should be the only global variable used which ...
-1
votes
1answer
33 views

HTML - Add movement in selections [closed]

I'm trying to work on a layout where you have 3 buttons that move constantly every 3 or so seconds. For example, on this website http://www.tigerdirect.com/ you have 4 button options to go through the ...
1
vote
1answer
58 views

The difference between bind and _.curry

So JavaScript's bind supports currying, but most people use some other library like lodash or ramda to do currying. From first impression It seems like bind supports context changing, since that is ...
0
votes
0answers
23 views

JavaScript top and left positions not working? [migrated]

I have this code in JavaScript on a html file but when i run it the image that i have doesn't move when i change top or left. Why is this happening, i have been searching for hours and copying tones ...
-3
votes
0answers
32 views

Looking for a package to visually show this [closed]

I want to be able to visualize a very long string of say 1000 characters in one line. From there the user can horizontally scroll through that long string of 1000 characters or zoom in to only see the ...
0
votes
1answer
50 views

Should the server and client portions of an SPA be separate repos? [closed]

I'm building an SPA (my first), and I had a question about organization. (I'm using Node.js for the server and Browserify & React for the client, and that's mildly important later). I'm unsure if ...
2
votes
0answers
39 views

Mapping different XML and CSV feeds

Not sure if this is the right venue to be asking this but here goes. A little background. I'm trying to build an ecommerce app that would allow sellers from other venues--like, amazon and newegg--to ...
2
votes
0answers
89 views

is this a valid javascript design pattern when many instances are required?

I have some code that I'm refactoring, right now its just a list of functions, primarily jQuery. The code is a form builder. The user adds sections, questions etc using jqueryUI drag/drop/sort. They ...
1
vote
1answer
103 views

What is the name of the pattern for passing an incomplete object to a constructor? [closed]

Several times in javascript I've seen a constructor function take in one parameter. The constructor will initialize all the fields for the object to default values and then use the parameter to ...
1
vote
3answers
209 views

Securing ajax calls to rest api

I need for my app to consume a rest api service and since I will call it from javascript/jquery i need to expose it to the end user. In this case I would also need to expose credentials to the end ...
1
vote
1answer
62 views

Best place to declare functions in this example

Suppose I have code that accepts html GET requests: server.get('path/to/some/endpoint', function(req,res) { function a() { //function goes here } } Is it better to declare functions ...
0
votes
2answers
113 views

The correct way of declaring & instantiating variables ( Javascript ) [duplicate]

I have seen other peoples code and each person has a different way of declaring variables. And I have been told by quite a few people that declaring variables in the Global Scope is wrong. My ...
0
votes
1answer
94 views

Switching over to the real ES6 / ES2015 [closed]

It is exciting time of having Babel and being able to use all nice nice features. It got me thinking, what happens in the future? Nobody really talks about it. I mean some browsers would eventually ...
-1
votes
1answer
46 views

Short Circuit Execution [closed]

Modify the car painting example car.color = favoriteColor ||"black"; so that the car is painted with your favorite color if you have one; otherwise it is painted with the the color of your garage: ...
4
votes
0answers
213 views

When to use Prototypes & the correct usage of Prototypes ( Javascript )

I have been programming in Javascript for a while and I am quite comfortable with it. And I know the basic concept of prototypes and I have also used them a few times. But one thing I can't figure out ...
3
votes
1answer
99 views

Importing plain javascript libraries in an AngularJs application

I am working on an AngularJs project which is getting bigger very fast. Currently I need to store some user data, so I was using $localStorage for Angular. But I had a problem, as the application is ...
-1
votes
0answers
26 views

Changing CSS Div Position Value Given in % Using Javascript [migrated]

Changing CSS Div Position Using Javascript I am really new to javascript, and I have searched for an answer to my question to no avail. I want to be able to click a button and change a div value ...
3
votes
1answer
101 views

Using a rules engine to manage client and server side validation of business rules?

Has anyone managed to use a common rules system between their frontend and backend? Similar to this question: Managing client-side and server-side validations in one place, I'm trying to find a way ...
1
vote
2answers
79 views

Where to declare event handlers: Markup or Script?

If the event handler is declared in the markup, it'd be (kind-of) adding presentation logic to HTML. <button id="btn" onClick="foo()">Click Me!</button> If the event handler is declared ...
0
votes
1answer
36 views

What is the difference between web components and custom elements?

"Web Components" and "Custom elements" are often mixed up, and web searches for the title of this question don't yet produce much clarity. Let's fix that.
47
votes
7answers
5k views

What is the actual value of a consistent code style

I am part of a consultant team implementing a new solution for a customer. I am responsible for the majority of code reviews on the client-side codebase (React and javascript). I have noticed that ...
2
votes
0answers
79 views

Preserving data in js with multipage application

One benefit of single page applications like Angular.js, is that you can store data in a global variable and access in multiple routes. With multiple page applications, the data is lost during ...
0
votes
3answers
237 views

How can I keep browser URL secret when editing data?

Suppose, There is a user list. <a href="user/5">Edit</a> <a href="user/6">Edit</a> When a system user clicked to edit a user info. Then it goes to url to browser like as ...
0
votes
0answers
4 views

Styling of charts externally [migrated]

Is it possible to translate(detach) bar colors stated in js file to separate css stylesheet. How to assign classes to this values? /* Bar dashboard chart */ Morris.Bar({ element: 'dashboard-bar-1', ...
1
vote
1answer
136 views

you don't know js book 'this' example [closed]

I am reading the book "you don't know js this & object" and I ran into below where they are explaining 'this'. Now, below example, I understand somewhat but I just do not understand what ...
0
votes
0answers
2 views

$.when().done() not working as expected [migrated]

I need to load html on to a page via jquery ajax. Then, after the html has loaded, I want to parse it for certain data that will be in the loaded html, and use it to create map markers. So I need the ...
2
votes
1answer
74 views

Conceptual question whether to pass data between functions or use a Class

I have a hard time to find an ideal concept / design and would appreciate your thoughts on this. I have 16 "tissues" that I need to keep track on. Each tissue holds a pressure that need to be ...
-1
votes
1answer
87 views

JS Asynchronous Load Pattern

This is a specific problem but I believe the pattern here may be general enough to be useful to the audience here. I'm working on an offline JS application. In my JS application, I would like to run ...
-1
votes
0answers
70 views

When should mixed PHP/JS snippets be refactored into a separate JS file? [duplicate]

This code snippet is from a teammate of mine, his title is "Full Stack Developer". He mostly write PHP code. I found this code at the end of a .php file and asked him to move it to a separate JS file ...
9
votes
2answers
552 views

Is automatically generating passwords during registration a good idea?

I'm developing a registration system for a project I'm working on. Since users tend not to sign up if the process is too long, I've thought to require (at least initially) just their email, where I ...
2
votes
2answers
157 views

Algorithm and data structure to match groups of users (1-5 each) into 2 balanced sets of 5 users

I'm building a matchmaking queueing service for a 5v5 team-based game. I have a large set of users that are grouped into unique lobbies comprised of 1-5 users each. Each user has an integer based ...
1
vote
1answer
116 views

How to avoid tying these two methods together with global mutable state?

I'm in the process of reading Code Complete 2 and learned that using global state is a no-no. What can I do to avoid using global state in this situation? Some background information: I have two ...
0
votes
0answers
58 views

Is it possible to cast Javascript anonymous object to a typed object? How? [migrated]

I'm looking for a way to cast JavaScript anonymous object to a typed Object, ... Using MooTools library (You may create them manually or using other tools), i defined several type, and then Using ...
0
votes
0answers
40 views

Static classes vs prototype classes whats the difference really

I am manage to create both static and prototype classes in this JS code, Keeping in mind that I will always need 1 instance of prototype class "Fruits" here, what benefit could I get over static ...
0
votes
1answer
37 views

maintain rate of animation with requestAnimationFrame

I've noticed that HTML game developers are recommending the use of requestAnimationFrame as opposed to a timer for the animation loop. I understand that this can be optimized by the browser, but how ...