JavaScript Vs. Ruby on Rails

Transitioning from Ruby to Javascript was a bit of a rocky road.. so i thought it would be cool to to a blog about them both, compare them & see a few differences and similarities :).

so let compare..

Equals sign.

: ==, =. ruby uses  to compare 
while using the to assign.
: ===, == , = javascript uses === to compare and also uses the == to compare the difference between these two is === is very accurate and == is leniate when comparing. meaning === checks for types & == does not. example:
a = 10
b = '10'
a b returns
a b returns
so thein is equivalent to in the in javascript is the as ruby. (it's used to assign)

&& and || (and & or)

JavaScript uses  and  the  as Ruby.

String Interpolation

this is  Javascript uses ticks  in the front and end of a string interpolation and uses  to interpolateexample:
`hey, this is a
string interpolation example`
Ruby uses a plain quotation mark in front and end of the string and uses to interpolateexample:
'hey, this is a string interpolation example'

Although you can still use the a couple of other ways to add strings together like
- .concat,
- the
operator, I find the previous example much simpler to use.

self vs. this

 is basically the same as .

Functions Vs. Methods

 (ruby) is equivalent to  (javascript)ruby example:  ruby
puts "hello"
javascript example:javascript() {
return "hello"


 is the  in as it is in example: { |string| }
only difference is the way the iteration is written... example: =>
Map with the results.
.each in ruby is the as forEach in javascript. Example...array = [1, 2, 3, 4]example:
array.each {|num| num}
array.forEach(num => num )

Object vs. Hash

 is the  as  javascript example:
const cat = {color: “grey”, name: “Spot”, age: “12”};
ruby example:
cat = {color: “grey”, name: “Spot”, age: “12”};
is ruby doesn't need to assign a variable a value.

camelCase vs. under_score

we name variables in  in ruby example: let javascriptVariable = camelCase javascript example:ruby_variable = under_score 

null vs. nill

Ruby's  is the same as Javascript's 

That’s just a few of the many similarities and differences… of JS and ruby hope this was a bit more helpful into conversion if you are converting..

thanks for the read :)