src/helper.js
function (variable, isRecursive) {

            var property, result = 0;

            isRecursive = (typeof isRecursive !== "undefined" && isRecursive) ? true : false;

            if (variable === false ||
                variable === null ||
                typeof variable === "undefined"
            ) {
                return 0;

            } else if (variable.constructor !== Array && variable.constructor !== Object) {
                return 1;
            }

            for (property in variable) {

                if (variable.hasOwnProperty(property) && !$this.isFunc(variable[property])) {
                    result++;

                    if (isRecursive && variable[property] &&
                        (
                            variable[property].constructor === Array ||
                            variable[property].constructor === Object
                        )
                    ) {
                        result += this.count(variable[property], true);
                    }
                }
            }

            return result;
        }
function (variable, isRecursive) {

            var property, result = 0;

            isRecursive = (typeof isRecursive !== "undefined" && isRecursive) ? true : false;

            if (variable === false ||
                variable === null ||
                typeof variable === "undefined"
            ) {
                return 0;

            } else if (variable.constructor !== Array && variable.constructor !== Object) {
                return 1;
            }

            for (property in variable) {

                if (variable.hasOwnProperty(property) && !$this.isFunc(variable[property])) {
                    result++;

                    if (isRecursive && variable[property] &&
                        (
                            variable[property].constructor === Array ||
                            variable[property].constructor === Object
                        )
                    ) {
                        result += this.count(variable[property], true);
                    }
                }
            }

            return result;
        }
function ( variable , isRecursive ) { var property , result = 0 ; isRecursive = ( typeof isRecursive !== "undefined" && isRecursive ) ? true : false ; if ( variable === false || variable === null || typeof variable === "undefined" ) { return 0 ; } else if ( variable . constructor !== Array && variable . constructor !== Object ) { return 1 ; } for ( property in variable ) { if ( variable . hasOwnProperty ( property ) && ! $this . isFunc ( variable [ property ] ) ) { result ++ ; if ( isRecursive && variable [ property ] && ( variable [ property ] . constructor === Array || variable [ property ] . constructor === Object ) ) { result += this . count ( variable [ property ] , true ) ; } } } return result ; }
Count all elements in an array, or something in an object

@link http://php.net/manual/en/function.count.php
@link http://phpjs.org/functions/count/

@param variable
@param isRecursive bool
@returns {number}
Count all elements in an array or something in an object