JS Basics to Building April 2nd, 2015

  • JavaScript has syntax AND grammar
  • Expressions and statements
    • Statements are 1:1 and end with a semicolon (e.g. a = b * 2;)
    • ‘2’ is a numerical expression
    • ‘b’ is an identifier expression
    • ‘b * 2’ is a mathematical expression
    • ‘a = b * 2’ is a statement expression
  • JavaScript uses operator precedence, but added unnecessary parenthesis are fine for aiding developer reading
  • JS gets compiled for error checking instead of interpreting line by line and then throwing an error
  • Console prints out different data types in different colors … numbers in blue are mathematical, whereas black is a string
  • .String(a) … is conversion … which is explicit
  • Coercion is implicit
  • Declare variables with var, let, const, or function d()
  • “falsy” values = 0, -0, Nan, “”, false, null, undefined
  • while (a) { … } – keep doing until ‘a’ is falsy
  • It’s an argument when it gets passed in, but it’s a parameter if you declare it … function(myParam)