Object.prototype.toString.call vs typeof/instanceof

Edit on GitHub

Setup

var x = 123;
var y = new Number(123);

Tests

  • Object.prototype.toString.call

    Object.prototype.toString.call(x) === "[object Number]";
    Object.prototype.toString.call(y) === "[object Number]";
  • typeof/instanceof

    typeof x === "number" || x instanceof Number;
    typeof y === "number" || y instanceof Number;