JavaScript for C# developers: some refactoring

I just published a blog post on my DevExpress ctodx blog about taking some non-idiomatic JavaScript code (actually from a DevExpress CodeCentral example program) and refactoring it to follow JavaScript best practices.

Topics covered include:

  • Minimizing the global namespace pollution
  • Using triple-equals instead of double-equals for comparisons
  • Function scoping
  • Passing JSLint tests by using declaration-first

Take a look!

Album cover for Carboot SoulNow playing:
Nightmares On Wax - Morse
(from Carboot Soul)



Posts on similar topics...

2 Responses

  • Wed 08 Dec 2010
  • 12:04 AM
  •  avatar #1

Marcel Doru Popescu said...

Good article, but I spent far too little time reading it and far too much being annoyed that the text is wider than the page (and thus the last words on each row, except for the first paragraph, are not visible). I tested it on three browser, so I doubt it was on my side.

  • Wed 08 Dec 2010
  • 8:09 AM
  • julian m bucknall avatar #2

julian m bucknall said...

Marcel: Yeah, it was all screwed up. I noticed it late last night and spent some time fixing it. It's now looking as I wanted it to in the first place.

Cheers, Julian

Leave a Response

Some MarkDown is allowed, but HTML is not. (Click to learn more.)

  • Emphasize with italics: surround word with underscores _emphasis_
  • Emphasize strongly: surround word with double-asterisks **strong**
  • Link: surround text with square brackets, url with parentheses [text](url)
  • Inline code: surround text with backticks `IEnumerable`
  • Unordered list: start each line with an asterisk, space * an item
  • Ordered list: start each line with a digit, period, space 1. an item
  • Insert code block: start each line with four spaces
  • Insert blockquote: start each line with right-angle-bracket, space > Now is the time...

Extras

Search

About Me

I'm Julian M Bucknall, the M because it's my middle initial and because I and the other Julian Bucknall (the movie guy) would like to differentiate ourselves.

I'm a programmer by trade, an actor by ambition, and an algorithms guy by osmosis. I write articles for PCPlus in my spare time, not that there's much of that.

Julian M Bucknall Apart from that, an ex-pat Brit, atheist, microbrew enthusiast, Pet Shop Boys fanboy, slide rule and HP calculator collector, amateur photographer, Altoids muncher.

DevExpress

I'm Chief Technology Officer at Developer Express, a software company that writes some great controls and tools for .NET and Delphi. I'm responsible for the technology oversight and vision of the company.

Validation

Validate markup as HTML5 (beta)     Validate CSS

Bottom swirl

Archives

May 2012 (4)
SMTWTFS
« Apr  
12345
6789101112
13141516171819
20212223242526
2728293031

Like this Archive Calendar widget? Download it here.

Social networking

The OUT Campaign

The OUT Campaign

My Tweets

  • Honest Movie Trailer of Phantom Menace http://t.co/sif8y4Ns and then Battleship, er, Transformers http://t.co/sif8y4Ns
  • Damn, Donna Summer and Chuck Brown both gone in the last 24 hours. Different types of music, sure, but enjoyed them both. :(
  • Just saw a company page showing a list of tweets with "Join the conversation" linked to their Twitter a/c. The tweets are 6 months old #fail
Bottom swirl