Questions tagged [javascript]

JavaScript (not to be confused with Java) is a high-level, dynamic, multi-paradigm, weakly-typed language used for both client-side and server-side scripting. Use this tag for questions regarding common implementations of ECMAScript, JavaScript, JScript, etc. JS does not typically refer to its ECMA-cousin, ActionScript.

Filter by
Sorted by
Tagged with
84
votes
6answers
20k views

Does immutability hurt performance in JavaScript?

There seems to be a recent trend in JavaScript towards treating data structures as immutable. For example, if you need to change a single property of an object, better to just create a whole new ...
25
votes
8answers
10k views

The importance of javascript and the best way to learn it? [duplicate]

I'm a new graduate, but I have been doing web development for about six months. When I was finishing university the server side languages (PHP, Java) were more important then client side languages. ...
45
votes
2answers
10k views

Strategy for generating unique and secure identifiers for use in a “sometimes offline” web app

I have a web based project that allows users to work both online and offline and I'm looking for a way to generate unique ids for records on the client side. I'd like an approach that works while a ...
60
votes
8answers
16k views

Client-side coding: How to prevent malicious use?

Over the last few years, the trend for client-side (browser) applications has really taken off. For my latest project, I have decided to try and move with the times and write a client-side ...
48
votes
6answers
15k 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 ...
36
votes
5answers
23k views

How easy is it to hack JavaScript (in a browser)?

My question has to do with JavaScript security. Imagine an authentication system where you're using a JavaScript framework like Backbone or AngularJS, and you need secure endpoints. That's not a ...
34
votes
8answers
23k views

When should JavaScript generate HTML?

I try to generate as little HTML from JavaScript as possible. Instead, I prefer to manipulate existing markup whenever I can and only generate HTML when I need to dynamically insert an element that ...
64
votes
14answers
14k views

Is it a bad idea to return different data types from a single function in a dynamically typed language?

My primary language is statically typed (Java). In Java, you have to return a single type from every method. For example, you can't have a method that conditionally returns a String or conditionally ...
32
votes
3answers
8k views

What does Douglas Crockford mean when he says jQuery doesn't scale? [closed]

In the Q&A section of this talk, Douglas Crockford says that jQuery doesn't scale as well as some other popular libraries. What does he mean by that, and what is it about the other libraries that ...
16
votes
5answers
10k views

Avoiding new operator in JavaScript — the better way

Warning: This is a long post. Let's keep it simple. I want to avoid having to prefix the new operator every time I call a constructor in JavaScript. This is because I tend to forget it, and my code ...
16
votes
4answers
3k views

Can't grasp programming design patterns

I've been working with javascript for the past 4 years. I'm very confident about my problem solving skills and I can see that my code quality is improving. I try to stay up to date with the community ...
20
votes
4answers
20k views

JavaScript's prompt, confirm and alert considered “old-fashioned” [closed]

Lately I've been developing a web-based management system for a gym. Their previous app was developed in Visual Basic. For the new app, all the front-end scripting uses jQuery, the server is running ...
27
votes
12answers
8k views

How did JavaScript become popular?

In ancient history, Brendan Eich had a language design, and in today's world, JavaScript is a popular language implemented and used in many different places. What caused the language to become ...
19
votes
6answers
6k views

Is it a good idea to do UI 100% in Javascript and provide data through an API?

My primary day job is making HTML applications. With that I mean internally used CRUD-type applications with lots of editable gridviews, textboxes, dropdowns, etc. We're currently using ASP.NET ...
32
votes
5answers
2k views

Why do code-bases in n-tier development have an equal amount of, if not more, JavaScript code now?

I've been doing web programming for a long time now, and somewhere, I lost track of why we are doing what we are doing today (or how did we come to do things this way)? I started out with basic ASP ...
21
votes
5answers
2k views

How do I convince my boss (and other devs) to use/consider Unobtrusive JavaScript

I'm pretty new in our develepors team. I need some strong arguments and/or "pitfall" examples, so my boss will finally understand the advantages of Unobtrusive JavaScript, so that he, and the rest of ...
17
votes
6answers
10k 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. ...
20
votes
5answers
5k views

What is the motivation behind TypeScript?

We had JavaScript, then we had Flash, then we had Silverlight and then HTML5 ownd them all. So what is the motivation behind TypeScript? What problems are going to be tackled and what improvements ...
19
votes
5answers
3k views

Dev approaches to complex JavaScript UI's [closed]

I am trying to understand the landscape of different approaches, and best practices, around the development of complex client-side JavaScript. I'm not sure what to label this class of application, ...
15
votes
10answers
14k views

Best approach for writing a chess engine? [closed]

I'm a chess enthusiast and a programmer. I recently decided to start making a chess engine using my chess and programming knowledge. So here's my question: What language (I'm familiar with Java, C++ ...
14
votes
4answers
31k views

What is a good IDE for client side JavaScript development? [closed]

I recently started learning JavaScript and am looking for a good JavaScript Editor/IDE. I found dozens of them in a Google search but I would appreciate if users who have experience with using such an ...
8
votes
3answers
2k views

Javascript simple code to understand prototype-based OOP basics [closed]

I know Javascript for some time, although I am not a heavy user, I know it the first from the time when Netscape was my browser. I pretty much understand the main things, but since JavaScript approach ...
19
votes
6answers
8k views

Why is Javascript used in MongoDB and CouchDB instead of other languages such as Java, C++?

I asked this question on SO but was suggested to try here. So here it goes: My understanding of Javascript so far has been that it is a client-side language that capture events and makes a web-page ...
10
votes
2answers
547 views

How do you unit test your javascript

I spend a lot of time working in javascript of late. I have not found a way that seems to work well for testing javascript. This in the past hasn't been a problem for me since most of the websites I ...
10
votes
3answers
1k views

What is the point of the prototype method?

I am reading through Javascript: The Good Parts, and struggled to get my head around the section on prototypes. After a little google, I came to the conclusion that it is to add properties to objects ...
4
votes
4answers
18k views

What's so useful about closures (in JS)? [duplicate]

In my quest to understand closures in the context of JS, I find myself asking why do you even need to use closures? What's so great about having an inner function be able to access the parent function'...
4
votes
1answer
3k views

Are Native Promises Still Slower in Node vs Libraries such as Bluebird? [closed]

Does this question still apply: Why are native ES6 promises slower and more memory-intensive than bluebird?? In regards to the latest versions of Node.js and EC7?
22
votes
6answers
16k views

Why do we still use JavaScript? [duplicate]

Possible Duplicate: Why aren't there other client-side scripting languages for websites? It seems to me that, despite being one of the world's most used languages, even some of the leading ...
12
votes
6answers
7k views

A testing environment for JavaScript other than browser? [closed]

When I want to test something in JavaScript, I open up a new browser window (mostly Firefox) and start writing code in the provided console (mostly Firebug). However, this tends to be really tedious ...
11
votes
5answers
2k views

Compute if a function is pure

As per Wikipedia: In computer programming, a function may be described as pure if both these statements about the function hold: The function always evaluates the same result value given the same ...
11
votes
5answers
3k views

What are you thoughts on GWT? [closed]

Since I'm learning Java in this period and I just finished with the tutorials I think I'm ready to start contributing to a project (since I know from experience this is the best way to really learn). ...
6
votes
4answers
1k views

Minimal programmer's definition of a monad

I am trying to formulate a definition of a monad without needing mathematical terms or Haskell to understand. Can a monad be thought of as a function that accepts a value and wraps it such that it ...
6
votes
2answers
3k views

How can I combine C/Fortran with JavaScript?

I'm working on a project where I need heavy numerical calculations to be real-time visualized with something flexible like D3.js. Are there frameworks out there that would let me painlessly achieve ...
3
votes
2answers
2k views

Proper way to structure JSON for front-end consumption

Having worked on several different web application code bases, I've seen some divergence in how back-ends serving JSON to front-ends structure that data. In particular, when a backend wants to return ...
20
votes
4answers
7k views

Why is JSX good, when JSP scriptlets are bad?

React.js provides JSX as an XHTML-like syntax for constructing a tree of components and elements. JSX compiles to Javascript, and instead of providing loops or conditionals in JSX proper, you use ...
14
votes
3answers
3k views

How to write manageable code with functional programming?

I just started with functional programming (with JavaScript and Node.js) and from the look of things it looks as if the code I am writing would grow to be one hell of a code base to manage, when ...
8
votes
2answers
2k views

Should the ternary operator be used outside of assignment statements?

Edit This isn't a question of whether or not the ternary operator is harmful. It's about whether or not there's a consensus about whether or not it should be used outside of assignment statements. /...
7
votes
4answers
5k views

Better ways than traditional polling methods

I'm currently in a AngularJS/Javascript environment. Currently the application using the polling method (i.e, to retrieve new data from server in a fixed amount of seconds). This is quite taxing ...
7
votes
3answers
788 views

Is there a canonical book on creating highly interactive websites (eg. “Flash” like) with HTML5/CSS3/JS/jQuery? [closed]

I know some of the basics of these technologies already, but it is mostly limited to more static sites. Using things like HTMl5 semantic elements, CSS3 gradients, shadows, @font-face etc. Is there a ...
4
votes
3answers
7k 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 ...
4
votes
4answers
1k views

Duplication of code (backend and javascript - knockout)

We have a new developer on our team. He seems to be a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements on the project (MVC3 web application ...
2
votes
2answers
832 views

With AMD style modules in JavaScript is there any benefit to namespaces?

Coming from C++ originally and seeing lots of Java programmers doing the same we brought namespaces to JavaScript. See Google's closure library as an example where they have a main namespace, goog and ...
2
votes
4answers
396 views

JavaScript only validation on AJAX form submit

I've been mulling this question over for a few days in my head and I can't come to a solid answer. We understand that client side validation for forms is not enough, because you can easily turn ...
14
votes
5answers
13k 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 ...
13
votes
7answers
3k views

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

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 ...
12
votes
1answer
893 views

Google Blink (new WebKit fork): Meaning of “Moving DOM into Javascript”?

From the Blink Blog: Finally we’d like to explore even larger ideas like moving the entire Document Object Model (DOM) into JavaScript. What does this mean? Does it mean WebKit's DOM is currently ...
10
votes
2answers
3k views

Fundamental Difference between fn() and new fn() in javascript

In what all aspects, calling a function with and without new keyword differ in javascript? I mean what all things are differing between? testFn() vs new testFn()
7
votes
3answers
15k views

How do you unit test a User Interface? [closed]

I use JavaScript with JQuery for a Rails application. I have some dynamic behaviour in this one. As a Ruby developper, I like TDD/BDD, specialy with RSpec. For the moment, I test my JavaScript manualy....
6
votes
2answers
1k views

Respectable design pattern for making node modules flexible/testable?

I am looking to get some input from some more experienced testers than what I am. :) I am trying to make my node modules testable, allowing for dependency spying/stubbing/mocking without the need to ...
6
votes
3answers
2k views

Is break a code smell?

I'm asking in terms of a loop, obviously break is important in switch statements. Whether or not switch statements themselves are code smells is a separate issue. So consider the following use cases ...