Login or Sign up

Javascript Introspection in 90 seconds.

Posted by: skyl on June 8, 2010

A javascript console (like those found in firebug, chrome, safari and elsewhere) is super-handy for learning javascript. You can click through objects to inspect them. You may want to find out a little about your values with code as well. Here is a little bit of introspection you could do on myval to see what kind of object it is.

typeof myval                  // "object"
typeof(typeof myval)          // "string"
myval.constructor.name        // "Date"
myval isinstance Date         // true
myval.hasOwnProperty('foo')   // false
myval.foo = 'bar'
myval.hasOwnProperty('foo')   // true

Comments on This Post:

Please Login (or Sign Up) to leave a comment