modules/utils.js
function betterTypeOf(input) {
    "use strict";
    switch (input) {
        case undefined:
            return 'undefined';
        case null:
            return 'null';
        default:
        try {
            var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
            if (type === 'object' &&
                phantom.casperEngine !== "phantomjs" &&
                '__type' in input) {
                type = input.__type;
            }
            // gecko returns window instead of domwindow
            else if (type === 'window') {
                return 'domwindow';
            }
            return type;
        } catch (e) {
            return typeof input;
        }
    }
}
function betterTypeOf(input) {
    "use strict";
    switch (input) {
        case undefined:
            return 'undefined';
        case null:
            return 'null';
        default:
        try {
            var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
            if (type === 'object' &&
                phantom.casperEngine !== "phantomjs" &&
                '__type' in input) {
                type = input.__type;
            }
            // gecko returns window instead of domwindow
            else if (type === 'window') {
                return 'domwindow';
            }
            return type;
        } catch (e) {
            return typeof input;
        }
    }
}
function betterTypeOf ( input ) { "use strict" ; switch ( input ) { case undefined : return 'undefined' ; case null : return 'null' ; default : try { var type = Object . prototype . toString . call ( input ) . match ( / ^\[object\s(.*)\]$ / ) [ 1 ] . toLowerCase ( ) ; if ( type === 'object' && phantom . casperEngine !== "phantomjs" && '__type' in input ) { type = input . __type ; } // gecko returns window instead of domwindow else if ( type === 'window' ) { return 'domwindow' ; } return type ; } catch ( e ) { return typeof input ; } } }
Provides a better typeof operator equivalent, able to retrieve the array
type.

CAVEAT: this function does not necessarilly map to classical js "type" names,
notably a `null` will map to "null" instead of "object".

@param  mixed  input
@return String
@see    http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
Provides a better typeof operator equivalent able to retrieve the array type .