The name of a variable is just a hint at what the function expects as input, but there is no real "type hinting" in Javascript that would enforce any such policy.
Hash/object are used interchangeably in Javascript because object members can also be accessed in a fashion that is similar to the syntax of how you would access entries in a hash table in other languages.
hash.w
is equivalent to
hash["w"]
The latter is a syntax common in languages such as Python or Ruby (in fact the class implementing this behavior is called "Hash" in Ruby).
So the word "hash" does not refer to a cryptographic hash or a hash function but rather to the functionality of a hash table.
Objects are often referred to as "Hashes" in Javascript if they are merely a collection of key/value pairs but don't implement any functions, e.g.
hash = {
a: 5,
b: "string",
c: 7
}
opposed to
object = {
member_a: 5,
member_b: "string",
do_this: function() { ... },
do_that: function() { ... }
}
var hash = arguments[0];, whereargumentsis a collection representing all the arguments passed when the function was invoked.