Index

Javascript Introspection

function introspect(introspectMe, message) {
    var functions = [];
    var objects = [];
    var properties = [];
    
    for(prop in introspectMe) {
        value = introspectMe[prop];
        type = typeof(value);
        
        if(type == 'function') {
            functions.push(prop);
        } else if(type == 'object') {
            objects.push(prop);
        } else {
            properties.push(prop + '[' + type + '] = ' + value);
        }
    }
    
    if(message) {
        window.console.log(message);
    }
    window.console.log('objects: ' + objects.toString());
    window.console.log('functions: ' + functions.toString());
    for(i=0; i<properties.length; i++) {
        window.console.log(properties[i]);
    }
    window.console.log();
}