Producing a nested data set from flat data
The number of nested loops can be reduced and doing so provides an opportunity to check your data for duplicate ids. This may not be necessary if you trust your source to provide good data.

var objectByCode={};

objects.forEach(function(o){
    // if( objectByCode[o.code] ) throw 'Duplicate codes';
    objectByCode[o.code]=o;
});

objects.forEach(function(o){
    if(o.areas){
        o.areas.split(",").forEach(function(c){
            if(objectByCode[c]){
                o.child.push(objectByCode[c]);
                objectByCode[c].remove=1;
            } // else { throw 'Code not found'; }
        });
    }
});

var sortedSet=objects.filter(function(o){ return !o.remove; });


Personally I would worry less about how many nested loops you have used and more about the potentially recursive data structure you are creating. This may prove difficult to work with if any of the children turn out to be their own ancestors. If for example the object with code C had area P then the resulting sortedSet would be empty. If B was a child of C then any naive attempt to list all descendants of B would result in a infinite loop.

If you are sure that your data will never contain this situation then you should be safe. If you are worried that this problem might occur a quick and dirty way to test for it is to use JSON.stringify which will throw an error when asked to produce the string equivalent of recursive objects.

try{
    JSON.stringify(sortedSet);
}catch(e){
    // how you decide to handle this is up to you
}


It might not be important to your application if this is the case, but be aware that your code may need to handle these situations.