Upgrade to Pro — share decks privately, control downloads, hide ads and more …

You don't know JavaScript

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.
Avatar for C1nde C1nde
October 03, 2015

You don't know JavaScript

Avatar for C1nde

C1nde

October 03, 2015
Tweet

Other Decks in Programming

Transcript

  1. >>> [] + [] "" >>> {} + {} NaN

    >>> [] + {} "[object Object]"
  2. >>> [] + [] "" >>> {} + {} NaN

    >>> [] + {} "[object Object]" >>> {} + [] 0
  3. >>> if (true) { console.log('Will be printed'); } >>> if

    (false) { console.log('Will not be printed'); }
  4. >>> if (new Boolean(false)) { console.log('hmmmm'); } hmm >>> if

    (Boolean(false)) { console.log('as expected'); }
  5. >>> 'a string' === 'a string' true >>> new String('a

    string') === 'a string' false >>> String('a string') === 'a string' true
  6. >>> var obj = { its: 1, an: 2, obj:

    3 }; >>> obj.its = null; >>> obj.an = undefined; >>> delete obj.obj;
  7. >>> var obj = {}; >>> var proto = Object.prototype;

    >>> proto.isPrototypeOf(obj); false >>> Object.isPrototypeOf(obj); false
  8. >>> var obj = new Object(); >>> var proto =

    Object.prototype; >>> proto.isPrototypeOf(obj); false >>> Object.isPrototypeOf(obj); false
  9. >>> var obj = {}; >>> var proto = Object.prototype;

    >>> proto === Object.getPrototypeOf (obj); true
  10. [~] > cat check.coffee obj = prop: value if obj.prop?

    console.log obj.prop [~] > coffee -b -p check.coffee var obj; obj = { prop: value }; if (obj.prop != null) { console.log(obj.prop); }