Friday, November 5, 2010

Learning JavaScript

My initial impression on JavaScript was that it was a basic language that wasn't really useful especially when you're writing a web page in ASP.NET or Java. After watching the lectures by Douglas Crockford I realized that JavaScript is a very powerful language that is simply structured differently, ex. functions are used to do almost everything.

I found it odd that there were many instances where something was clearly not working in the language and were never fixed or adjusted, ex. the typeof function will return object on null and array.

Tips and tricks:

1. Comparison operators (===) and (!==) will compare both type and value which makes it faster than == and != and more reliable.

2. Don't use the Integer, Boolean objects, etc. They have no advantage.

3. If a variable is used but not declared it's recognized as a global variable.

4. parseInt("08") === 0
    parseInt("08",10) === 8


Here are some useful links:

Coding Conventions: http://javascript.crockford.com/code.html

JSLint - Provides code validation: http://www.jslint.com/

No comments:

Post a Comment