???? ???????? on 2012-04-10 09:56:27
If I might —perhaps you should consider adding a few images. I don’t mean to disrespect what you’ve said ; its very enlightening, indeed. However, I think would respond to it more positively if they could be something tangible to your ideas
Kevin van Zonneveld on 2008-12-30 12:36:56
@ Brett Zamir: Awesome!
Brett Zamir on 2008-12-21 06:40:17
And here's get_defined_vars(). As far as iterating deeper over its object properties to get a few other globals, the function turns up 'document' and 'location' which would not otherwise be present.

function get_defined_vars() {
 
	var i = '', ct = 0, obj = {};
 
	for (i in window) {
		try {
			// if (typeof window[i] !== 'function') { // Uncomment if wish to ignore functions (though in JavaScript, they really are variables) // sessionStorage gives errors here in Mozilla
			obj[i] = window[i];
			if (typeof window[i] === 'object') {
				for (var j in window[i]) { // 'history', 'globalStorage' gives errors here in Mozilla
					if (window[j] !== undefined) { // window/parent/top/frames/self give errors here in Mozilla
						// if (typeof window[j] !== 'function') { // Uncomment if wish to ignore functions (though in JavaScript, they really are variables)
 						obj[j] = window[j];
						// }
					}
				}
			    }
		    // }
		}
		catch (e) {
		}
		ct++;
	}	
	// window.length = ct; // Uncomment if wish to create an array-like object
	return obj;
}

Brett Zamir on 2008-12-21 03:30:10
Here's a slight improvement...For some reason, in Mozilla at least, you actually have to iterate over the window properties which are objects to get a few other globals not returned by a mere iteration of window itself (in Mozilla, these are: QueryInterface, addEventListener, getComputedStyle).
function get_defined_functions() {
    // http://kevin.vanzonneveld.net
    // +   original by: Brett Zamir
    // %        note 1: Test case 1: If get_defined_functions can find itself in the defined functions, it worked :)
    // *     example 1: function test_in_array(array, p_val) {for(var i = 0, l = array.length; i < l; i++) {if(array[i] == p_val) return true;} return false;}
    // *     example 1: funcs = get_defined_functions();
    // *     example 1: found = test_in_array(funcs, 'get_defined_functions');
    // *     results 1: found == true
 
    var i = '', arr = [], already = {};

    for (i in window) {
        try {
            if (typeof window[i] === 'function') {
                if (!already[i]) {
                    already[i] = 1;
                    arr.push(i);
                }
            }
            else if (typeof window[i] === 'object') {
                for (var j in window[i]) {
                    if (typeof window[j] === 'function' && window[j] && !already[j]) {
                        already[j] = 1;
                        arr.push(j);
                    }
                }
            }
        }
        catch (e) {
 
        }
    }
 
    return arr;
}