Skip to content

Instantly share code, notes, and snippets.

@danielnmai
Created June 13, 2017 04:30
Show Gist options
  • Save danielnmai/ce265742118bfbb9b44d38bfd5dec8a3 to your computer and use it in GitHub Desktop.
Save danielnmai/ce265742118bfbb9b44d38bfd5dec8a3 to your computer and use it in GitHub Desktop.
Today I Learned - Week 7
---------6/12/2017------------
Javascript
It can return unexpected results
> 5 + "2" => "52"
> 5 - "2" => 3
parseInt("342")
342.toString()
type comparison: 5 === '5' => false (strict)
5 == '5' => true (loose)
Javascript falseys:
false, null, undefined, 0, "", NaN
Math.floor() round down the number (10.9 => 10)
Math.ceil() round up the number (10.9 => 11)
Javascript constructors: similar to Class in Ruby
function Car(model, make, year) {
this.model = model;
this.make = make;
this.year = year;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment