JavaScript tips

I was writing a lot of jQuery and JavaScript this weekend, and two tips that I would like to jot down for future reference:

1. Place open brace on new line in Visual Studio

I used to place open brace on new line, so my codes would look more tidy with proper indentation.

Enable this feature in Visual Studio: Tools > Options > Text Editor > JScript > New Lines

2. No function overloading in JavaScript

I thought JavaScript is similar to C#, so I wrote few functions with different signatures. However, the fact is not and it doesn't work like as I expected. <sigh>

2 Comments

  • Why don't you put some examples. To me, this is completely incoherent. Like, you though JS is similar to C# so you wrote functions with different signatures. I you thought they were similar, why didn't write the functions similar?

  • Javascript supports optional parameters. In fact, all parameters in every javascript function are optional. Any errors that occur would be a result of the function body not handling unpassed params, not 'interpret time' errors.

Comments have been disabled for this content.