Crockford's Javascript Style Guide from 2007

Date: 2015-04-28

Douglas Crockford: The JavaScript Programming Language (1 of 4)
https://www.youtube.com/watch?v=v2ifWcnQs6M

In this 2007 presentation at Yahoo!, which is meant to be the beginning of a three-course sequence (followed by "Theory of the DOM" and then "Advanced JavaScript"), Douglas Crockford explores not only the language as it is today but also how the language came to be the way it is.

Style

  1. 1:19:40 - START
  2. 1:41:00 - Read about them at: http://javascript.crockford.com/code.html
  3. 1:41:25 - use semicolons - avoid the bad compiler patch
  4. 1:42:20 - Break a line after a punctuators - defend against copy/paste errors
    Do not break after a name, string, number, or ) ] ++ --
  5. 1:42:55 - Avoid tricky comma expression – especially with array literals
  6. 1:43:20 - Require blocks around structured statements to reduce ambiguity -
  7. 1:43:55 - Blocks don't have scope in Javascript - use only for function, if, switch, for, do, try
  8. 1:44:15 - define all variable at the top of the function - leverage function scope
  9. 1:44:40 - Limit expressions to assignment and invocation - avoid expressions that look like statements
  10. 1:45:20 - Avoid fall through in switch statements - break, return or throw
  11. 1:45:32 - Do NOT use assignment expressions in the conditional parts of if, while or for
  12. 1:45:55 - Avoid the type coercion of == and !=  – and USE ===, !== or !
  13. 1:47:00 - Only put labels on do, for, switch and while; never use javascript: as a label
  14. 1:47:25 - Crockford plugs his JSLint
  15. 1:48:50 - END - reviews his talk.


Content Network Distribution by: