Slides

Hash

corned beef hash

  • during breakfast, hash is a delicious processed meat product
  • during coding, a hash is an abstract data type

(image credit: Jeffrey W, CC-BY )

What makes a hash a hash?

a hash is an

  • unordered
  • indexed (by strings, not numbers)
  • collection
  • of key/value pairs

In other words, a hash defines a mapping from one group of things to another, like a phone book or a dictionary.

a hash is also known as a...

  • map or mapping
  • dictionary
  • associative array
  • lookup table
  • key/value store

hash or object?

In JavaScript, a hash is officially called an object.

This is confusing since in every other computer language, "hash" and "object" are quite different things.

Object != Object-Oriented

  • Just using an object as a key-value store does not make your code object-oriented.
    • For OOP you need a few extra features, especially the keywords new and this and class
    • We discuss OOP in a separate OO_JS track
  • In the rest of this lesson we use "object", but elsewhere, you may see "hash" and "object" used interchangeably

Suggested Projects