Key Points Every Programmer Should Remember About JavaScript

AES Encryption - codersTool

I’ve been build javacript applicaiton for about 12 months now and have made a bit of effort to help out a few developers with some starter tips. I thought it would be a good idea to share them with everyone. These are all either things that I wish I’d known when I started out, or things that really helped me master Javascript.

I’m going to assume that you know the absolute basics and is familiar with the language constructs.

Key Points to Remember About JavaScript:

  1. Javascript function declarations can be used by any code in the file no matter its location (before or after the function declaration).
  2. A Javascript function declaration defines a named function variable without requiring variable assignment.
  3. Function declarations occur as standalone constructs and cannot be nested within non-function blocks.
  4. Avoid falling into the trap of mismatched quotes, parentheses and brackets. Always code the opening & closing element at the same time.
  5. If you have a bunch of parenthesis, count the opening parenthesis and then the closing parenthesis, and make ensure the two numbers are equal.
  6. Javascript is loosely typed, except in switch statements. JavaScript is NOT loosely typed when it comes to case comparisons.
  7. The last property in any JavaScript object definition must never end with a comma.
  8. JS Variables that are not declared with the var keyword are global.
  9. Remember to declare Javascript variables with the var key term to keep variables from having global scope.
  10. When you declare a JS function more than once, the last declaration of that function will overwrite all previous version of that function.
  11. There is no overloading in javascript. This makes it vitally important to not use the names of core javascript functions in your code.
  12. The for loop in javascript will iterate over all object attributes, both methods and properties.
  13. Null is for an object, undefined is for a property, method or variable. To be null, your object has to be defined.
  14. If your object is not defined, and you test to see whether it’s null, since it’s not defined, it can’t test, and will throw an error.
  15. A function declared with a variable assignment syntax can only be used by code that executes after the assignment statement that declares the function.