Tuesday, February 26, 2013

Java Script variables and data types

Variables

js variables are case-sensitive.

Must start with _ $ a A
Can contain numbers

var a_string = "hello";

Escape characters 

\"
\'
\\
\t
\n

Four Data Types

  • Numbers (16-digit precision)
  • Strings
  • Booleans
  • Objects
Arrays are treated as objects in js.

Special values: null and undefined

var v = "xyz";
var sType = typeof(v);

= is assignment
== comparison regardless of type, 2 == "2"
=== comparison, 2 != "2"