Remove the [] array brackets from single record collections - Node.js Array

Node.js examples for Array:Remove Element

Description

Remove the [] array brackets from single record collections

Demo Code


function cleanSingleRecord(val) {
    // Remove the [] array brackets from single record collections (e.g. settings).
    val = JSON.stringify(val);/*from  w  ww  . j a  v a2s.c o m*/
    val = val.substring(1, val.length-1);
    return JSON.parse(val.trim());
}

Related Tutorials