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
12
votes
2answers
4k 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()
12
votes
3answers
2k views

How do you use duck typing in javascript without always checking for properties and methods?

I know javascript uses duck typing and at first I thought this would make polymorphism easy compared to strongly typed languages like C#. But now my functions that take arguments are littered with ...
12
votes
2answers
13k views

Webkit as GUI in .Net/Mono

I want to make a cross platform application, which will also have a website where the desktop applications (Windows, iOS, Linux) will talk to the server and keep the users data in sync. So far the ...
12
votes
3answers
2k views

Should I nest functions in languages that allow me to do that or should I rather avoid it?

In JavaScript, PL/SQL and some other languages, functions can be nested, i.e. declared within another function. This could be used to break a large function into smaller pieces, but keep those pieces ...
12
votes
6answers
7k views

How are large JavaScript applications supposed to be structured?

I've recently been shown some JavaScript plugins written for OBIEE Mobile App Developer, as well as some custom libraries for various projects. Coming from an OOP background, I am a little confused ...
12
votes
3answers
3k views

Different callbacks for error or error as first argument?

We (and the JS SO chat room) had a talk with @rlemon some days ago about his Little-XHR library about error handling. Basically, we wanted to decide which error handling pattern should be used: xhr....
12
votes
3answers
1k views

What should be tested in Javascript?

At work, we've just started on a heavily Javascript based application (actually using Coffeescript, but still), of which I've been implementing an automated test system using JsTestDriver and fabric. ...
12
votes
2answers
11k views

Find the new coordinates using a starting point, a distance, and an angle

Okay, say I have a point coordinate. var coordinate = { x: 10, y: 20 }; Now I also have a distance and an angle. var distance = 20; var angle = 72; The problem I am trying to solve is, if I want ...
12
votes
3answers
6k views

Object Oriented Programming in JavaScript. Is there life without it? [duplicate]

At our company we have pretty large body of PrototypeJS based JavaScript code, which we are porting to jQuery for several reasons (not really important here). I'm trying to set up coding guidelines to ...
12
votes
2answers
1k views

Functional reactive programming — is Fay expressive enough?

So I'm doing a fairly involved javascript/html client with lots of ajax calls and other involvements of callback-ism. I'm entertaining the thought of using Fay for this purpose. I'm aware of Elm. ...
12
votes
3answers
831 views

Why can we delete some built-in properties of global object?

I'm reading es5 these days and find that [[configurable]] attribute in some built-in properties of global object is set to true which means we can delete these properties. For example: the join ...
12
votes
1answer
2k views

Patterns for ajax-heavy web applications

Up until now, I've been a great fan of the MVC pattern for developing web applications. For the web, I've developed mostly in PHP (with the Kohana and CodeIgniter frameworks) and Ruby (RoR). As my ...
11
votes
14answers
1k views

Should I worry about 'Javascript piracy'?

If I write a client-side Javascript app (with a little bit of server interaction), how can I prevent people from copying the Javascript files to their own site? Should I, at all?
11
votes
3answers
1k views

How can I prevent a user from editing my code in their browser?

Description I'm designing a Node.JS application (more like a full website). The app will send five JavaScript files and will have <script> tags linking them together. Question How can I prevent ...
11
votes
6answers
7k views

Web Developer and Math [duplicate]

I have just learned HTML/CSS and I practice everything I read to make it more understandable to me and I really enjoy it. My goal is to be a Modern Web Developer both front and back-end, so I won't ...
11
votes
5answers
87k views

Falsy values vs null, undefined, 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 ...
11
votes
5answers
3k 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
3answers
6k views

When and Where should we use hoisting in Javascript [closed]

I'm new to Javascript. I'm learning the concept of hoisting in Javascript. Based on the Javacsript tutorials in Mozilla website, I came across this word hoisting. According to those tutorials, ...
11
votes
5answers
6k views

When a task can be accomplished by either Javascript or CSS, is it better to use CSS? [closed]

I always veto JavaScript by using CSS as much as possible. i.e. I create tabs and rollover buttons using CSS rather than JavaScript. I have seen some solutions—specifically the Wt web-framework—...
11
votes
4answers
5k views

What exactly undefined means in JavaScript? Why it's there? What usages it has? How it could be useful?

In JavaScript, we have something called undefined. I said something, because I really don't know if it's a base class, or a built-in variable, or a keyword, or anything else. I just know that it's ...
11
votes
4answers
3k 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 ...
11
votes
3answers
1k views

JavaScript and the paradigm shift in web programming

If my memory serves me right, there was a time when using JavaScript for web development was hugely frowned upon, because among other things, it was a privacy and security concern for users and some ...
11
votes
4answers
5k views

Should I invest time learning Coffeescript? [closed]

I am a freelancer and I earn my bread and butter by helping others write better java-script code. I have good experience with most of the JavaScript frameworks around. I am wondering if it is worth ...
11
votes
5answers
12k views

What is the advantage of assigning a function to a var?

Given this Javascript example I found var sum = function() { var i, sum = 0; for(i = 0; i < arguments.length; i += 1) { sum += arguments[i]; } return sum; }; What advantage is there ...
11
votes
6answers
4k views

How can I write HTML, CSS, and JavaScript to make back-end developers work easier?

When I get a design from a designer, I get it as a PSD (Photoshop) file. I always expect proper layer and folder names, basically a clean and managed PSD. From this desigbn I develop HTML, CSS and ...
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). ...
11
votes
4answers
4k views

Are there any limitations of an idealistic HTML5 web application

Let's assume the following two assumptions are true. Your entire userbase has broadband access everywhere There is an imaginary browser X that implements the entire draft specification of the HTML5 ...
11
votes
4answers
826 views

How does the GPL work in regards to languages like Dart which compile to other languages?

Google's Dart language is not supported by any Web Browsers other than a special build of Chromium known as Dartium. To use Dart for production code you need to run it through a Dart->JavaScript ...
11
votes
3answers
2k views

How is type checked in a dynamic language interpreter/compiler, such as JavaScript?

In dynamic languages, such as JavaScript or Python, the type of a variable is determined at runtime. This is one reason why they are slower than typed languages such as Java. How is type checking ...
11
votes
4answers
22k views

Which Java based web ui framework to use? [closed]

Wicket Click GWT Vaadin As I understand them, these frameworks all enable gui components to be created using java (with all its benefits) without having to do lots of html/javascript. As well as ...
11
votes
4answers
3k views

How do you keep code with continuations/callbacks readable?

Summary: Are there some well-established best-practice patterns that I can follow to keep my code readable in spite of using asynchronous code and callbacks? I'm using a JavaScript library that does ...
11
votes
3answers
3k views

Are there open-source JavaScript libraries addressing multiple browser tabs and client state for newer browsers? [closed]

There are a few new HTML5 features that have made it into recent browsers that allow sharing state among tabs, browser windows, same domain windows, etc. So it's probably gotten a little easier to ...
11
votes
2answers
464 views

How do mashups work with same-orgin policy?

If Javascript is only allowed to access scripts from the same domain, how can a website create mashups which must read and modify content from another domain?
11
votes
2answers
15k views

What is the recommended approach for helper functions in JavaScript?

What is the recommended approach for helper functions? I would like to choose one technique, and run with it to create my new "class". Here are the design options I have pondered: Option 1: Helper ...
11
votes
2answers
3k views

What are my choices for server side sandboxed scripting? [closed]

I'm building a public website where users share data and scripts to run over some data. The scripts are run serverside in some sort of sandbox without other interaction this cycle: my Perl program ...
11
votes
1answer
3k views

Convention to where to declare module.exports on Javascript files

Is there any convention to where we should declare the module.exports no Javascript/Node.js module files? Should it be in the beginning of the file like: module.exports = Foo; function Foo() { ...
11
votes
2answers
5k views

How to modularize and package a client-side Javascript library today?

I've been catching up with the modern client-side JS ecosystem and reading up on CommonJS and AMD (incl. associated tools - browserify, requirejs, onejs, jam, dozens of others). If I'm writing a ...
11
votes
1answer
870 views

Order and filter Server-Sent-Events in angular.js eventsource

I have a Client in AngularJS where I consume multiple SSE (Server-Sent-Events) in Java from the Server Side (there are multiple endpoints in different web servers in the backend). Diagram link I ...
10
votes
8answers
19k views

Is it necessary to memorize code?

I am a new developer, who just got hired at a big company. I don't know how but I guess they are desperate. However, I am well-versed with HTML5/CSS3 though things change and new things are released ...
10
votes
11answers
16k 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 ...
10
votes
8answers
4k views

Rush to client-side in web development

In the past few months, I recognized a big excitement about client-side scripting in web development. But while server-side technologies are mature, stable and well accepted by backend-developers, ...
10
votes
7answers
2k views

Should you make use of 'accidental polymorphism'?

Sometimes I find myself in situations where just by happenstance two things can be treated the same way. But they aren't truly the same, it's just coincedence. Let me give an example, imagine we are ...
10
votes
5answers
1k views

Is it beneficial to study past the basics of a core language when the primary goal is to rely on its framework? [closed]

Please keep in mind this is not another 'How much [insert programming language here] should I know before moving onto [insert framework here]?' What I'd like to know is how beneficial is it to learn ...
10
votes
3answers
1k views

Has Javascript developed beyond what it was originally designed to do?

I've been talking with a friend about the purpose of Javascript, when and how it should be used, etc. He quoted that: JavaScript was designed to add interactivity to HTML pages [...] ...
10
votes
5answers
962 views

How can I actually apply the javascript I am learning [closed]

I am a front end programmer. I'm good with design, html, css, and jquery, but I want to learn javascript more than anything. I've taken a couple of courses, read books and tutorials online and feel ...
10
votes
5answers
4k views

PHP, HTML, Javascript and writing good practices

I realized I have to write down a convention specification about HTML, JavaScript and PHP coding for me and my team. In web development, just like in C++, I'm definitely a fan of indentation and ...
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 ...
10
votes
4answers
8k 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 ...
10
votes
2answers
1k 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 ...
10
votes
4answers
17k views

Is node.js a good fit for background processing?

I'm slowly learning node.js and have a small project I want to start. The project will have a lot of background processes (downloading data from external sites, parsing CSV files, etc.). A big "win" ...

1
3 4
5
6 7
40