Javascript Array buildQueryString()

Description

Javascript Array buildQueryString()


Array.prototype.buildQueryString = function() {
    var queryString = '',
        delimiter   = '';

    for(var key in this) {
        if (!this.hasOwnProperty(key)) {
            continue;// www.ja va  2  s  .  c  om
        }

        queryString += delimiter + encodeURIComponent(key) + '=' + encodeURIComponent(this[key]);

        delimiter = '&';
    }

    return queryString;
};



PreviousNext

Related