/*global document, prompt */ (function( global ) { "use strict"; var response = { browser: { name: prompt( "Browser Name? (Chrome, IExplorer, etc)" ), version: prompt( "Browser Version? (34, 11, etc)" ) }, root: "window", properties: Object.getOwnPropertyNames( global ).sort() }; function addIfDistinct ( arr, key ) { if ( 0 > arr.indexOf( key ) ) { arr.push( key ); } } response.properties.forEach(function ( prop, index, array ) { var obj = { "property": prop }, self = global[ prop ], regex = /[a-z]+\s[A-Z][a-z]+/, props = [], proto; if ( self instanceof Object ) { proto = Object.getPrototypeOf( self ); obj.own = Object.getOwnPropertyNames( self ).sort(); while ( proto ) { Object.getOwnPropertyNames( proto ).forEach( addIfDistinct.bind( null, props ) ); proto = Object.getPrototypeOf( proto ); } obj.proto = props.sort(); if ( self.prototype ) { props = Object.getOwnPropertyNames( self.prototype ); obj[ ".prototype" ] = props.sort(); } } array[ index ] = obj; }); document.body.textContent = JSON.stringify( response, null, 4 ); }( this ));