Ruby vs. JavaScript

9/14/15

For all that they're alike, Ruby and JavaScript do vary in some fairly KEY (pun very much intended) ways. One of those in how they match collections of data to key values: ie, the Ruby hash and the JavaScript object.

As we already know, in Ruby, a hash as a one key, one value relationship, and while values don't have to be unique, keys do:


  hash = {"hello"=>"goodbye", "yes"=>"no"}
 

A Ruby object, on the other hand, doesn't have the same one-to-one relationship. One key (the name of the variable) can store a whole list of things:


 var test = {
 one: a,
 two: b,
 three: c
};

Ruby might give us an advantage, in that we can pull up individual elements, whereas we must the entire object with JavaScript. However, JavaScript's advantage is the ability to store all the relvenant data in one place, instead of spread out through a variety of key and value data sets.

And that's all she wrote today! I hope that was helpful!