Saturday, July 4, 2015

typeof in JavaScript

  1. var x = function(){};
    alert(typeof x);

       ...is going to bubble up: function
     
  2. var x = 33;
    alert(typeof x);

       ...is going to bubble up: number
     
  3. var x = "Hello World.";
    alert(typeof x);

       ...is going to bubble up: string
     
  4. var x = {
       y: "why not?"
    }
    alert(typeof x);

       ...is going to bubble up: object
     
  5. etc.

No comments:

Post a Comment