Serialization function for the Array datatype - Node.js Array

Node.js examples for Array:Array Operation

Description

Serialization function for the Array datatype

Demo Code


/**//from w ww .j  a  va2  s . c  o m
 *  Serialization function for the Array datatype. It reuses the
 *  other serialization functions to serialize the members of the array.
 */
Array.prototype.serialize = function()
{
    var result = '<array><data>';

    for ( var i = 0; i < this.length; i++ )
    {
        result += '<value>' + this[ i ].serialize() + '</value>';
    }

    result += '</data></array>';
    return result;
}

Related Tutorials