var newFieldShow = function(hash) {
hash.w.fadeIn("2000");
};
I see this in some code I have retrieved from online. I’ve never seen hash mentioned.. I am trying to determine if it has something to do with hashing, or if it’s just an event reference like function(event) which I’m used to seeing, and curious as to why it is being used here.
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.
is equivalent to
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.
opposed to