Skip to content

Instantly share code, notes, and snippets.

@samarpanda
Last active August 29, 2015 14:17
Show Gist options
  • Save samarpanda/1ccf96129dcc832d55fc to your computer and use it in GitHub Desktop.
Save samarpanda/1ccf96129dcc832d55fc to your computer and use it in GitHub Desktop.
Data Types, Operators and Primitives

Primitive DataTypes

  1. Undefined => undefined
  2. Null => null
  3. Boolean => true
  4. String => "hello"
  5. Number => 2

Object DataTypes

  1. Object (Object can be refered as Hash as key value pairs.)
  2. Array
  3. Date
  4. RegExp
  5. Function

Operators

  1. var
  2. new
  3. assignment
  4. delete
  5. member
  6. call
  7. comparison

typeof

  1. Undefined -> "undefined" (Unreferenced pointer)
  2. Null -> "object" ()
  3. Boolean -> "boolean" ()
  4. Number -> "number"
  5. NaN -> "number"
  6. String -> "string"
  7. Function -> "function"
  8. Array -> "object"
  9. Any other Object -> "object"

"==" vs "==="

  1. 21 == "21" -> true
  2. undefined == null -> true
  3. undefined === null -> false
  4. 21 === 21 -> true
  5. {} === {} -> false
  6. NaN === NaN -> false
  7. true === {valueOf: function(){return "1"}}

"==" comparison flow diagram

1

"===" comparison flow diagram

2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment