Skip to main content

All Questions

43 votes
6 answers
14k views

Should I place functions that are only used in one other function, within that function?

Specifically, I'm writing in JavaScript. Let's say my primary function is Function A. If Function A makes several calls to Function B, but Function B is not used anywhere else, then should I just ...
Gary's user avatar
  • 533
42 votes
9 answers
7k views

Is a JS Boolean having custom properties a bad practice?

In JS you can return a Boolean having custom properties. Eg. when Modernizr tests for video support it returns true or false but the returned Boolean (Bool is first class object in JS) has properties ...
konrad's user avatar
  • 551
42 votes
5 answers
5k views

How to avoid typical "dynamic language mistakes"?

I've recently poured a couple of hours into JavaScript because I wanted to benefit from the massive userbase. Doing that I have noticed a pattern that most people attribute to dynamic languages. You ...
TomTom's user avatar
  • 531
34 votes
1 answer
39k views

I know JavaScript really well, but i bomb coding interviews [closed]

So I'm currently on a hunt for a new position as a Front-End Developer. I know JavaScript very well and can wax poetically about Closures, Currying, Prototypal Inheritance, Design Patterns, App ...
Mike Fisher's user avatar
33 votes
5 answers
7k views

Why do we need enums in dynamically typed languages?

I was reading some code here and saw that an enum is used to store names of html tags. Why do we ever need to do this? What benefit do I get using this strategy? I know that how useful enums are in ...
CodeYogi's user avatar
  • 2,186
32 votes
5 answers
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 ...
Jane Wayne's user avatar
17 votes
4 answers
7k views

Why does Facebook obfuscate the names of CSS classes?

If you look at the source code of a website such as Facebook, you'll see many classes as such: <div class="_cy6 _2s24"><div class="_4kny"><div class="uiToggle _8-a _1kj2 _4d1i _-57 _5-...
1234567's user avatar
  • 335
11 votes
1 answer
5k views

Is it bad practice to require the same module in multiple files in Javascript?

Let’s say I have three files, all of which import a fairly large module. But I’ve divided them because they have different functions. Now each of the JavaScript files needs an initial statement like ...
elbecker's user avatar
  • 121
9 votes
2 answers
11k views

Is it good practice to use array.pop() assignment in a while loop condition?

Just saw a code snippet that used an array pop assignment in the while condition; was wondering if this is acceptable/good practice? var arr = [0,1,2,3,4,5]; var current; while (current = arr.pop()) {...
flewk's user avatar
  • 103
7 votes
3 answers
13k views

Why is it a good practice to keep Javascript code in separate files?

In web development we are commonly used to keep Javascript code in separate files, but sometimes we need this Javascript code to manipulate server side data locally. For example, making an Ajax Call ...
TheByeByeMan's user avatar
7 votes
2 answers
11k views

How to structure a modern web application

Background I recently developed, for two different projects, two web applications. The two followed quite different approaches. The first one was a classic inventory application (lists of stuff to ...
Lorenzo Dematté's user avatar
5 votes
3 answers
972 views

Weighing pros and cons for using jQuery for just one widget

I have been using html select boxes or textboxes for date input. On submit, the date is validated and if invalid an error is returned. I have avoided javascript calendars thus far, but jQuery ...
abel's user avatar
  • 697
5 votes
1 answer
4k views

Approaches to reduce cyclomatic complexity

I was running our code through JSHint, and decided to switch checks against cyclomatic complexity, and then went on long refactoring sprint. One place though baffled me, here is a code snippet: var ...
David Sergey's user avatar
5 votes
3 answers
503 views

Functions that contain single statement?

Is it OK to have functions that have single statements? I usually make functions that have single statements. I believe these increases code readability and i am able to write code faster as they ...
Gaurav Grover's user avatar
4 votes
1 answer
752 views

How dangerous is it to take shortcuts when coding Web based applications? [closed]

I started working as a Web developer few months back. Previously, I had no prior professional experience in programming besides school classes and fun-side projects I did on my own. I am the only ...
HelpNeeder's user avatar

15 30 50 per page