I have a piece of code where I have string pairs (eg. 'a' and 'AA'), where both have their own unique ids. Id for first object is configured by user and second id is received at some point during runtime.Example code:http://repl.it/BE5NIs there smarter way to load/save second ids from/to a file?It feels somewhat unnecessary to loop through all configs every time new id is found (even if it doesn't happen that often)And if I added completely new pair-configs during runtime, how should I add them to user's config file while still keeping it human readable?Initial setup:var fs = require('fs');// config pair for first and secondfunction config (first, second, first_id) {    this.first    = first;    this.second   = second;    // use name as an id for first if none is given    this.first_id = first_id ? first_id : first;}var lookup = function (type, name, arr) {    return arr.filter(function (obj) {        return obj[type] === name;    })[0];};// initial config file (few lines out of many)// user doesn't know second idsconfigs = [    new config('a', 'AA', 'a_id'),    new config('b', 'BB'),    new config('c', 'C'),    new config('d', 'D', 'd_id'),    new config('e', 'EEE')];// read ids for seconds from file if it exists// read json from fileinput_json = {AA:123,C:321,EEE:456};for (var i=0; i<configs.length; ++i) {    var key = configs[i].second;    if (key in input_json) {        configs[i].second_id = input_json[key];    }}While program is running and new id's are found:// add new id for 'BB'BB_config = lookup('second', 'BB', configs);BB_config.second_id = 654;// write edited json to filevar output_json = {};for (var i=0; i<configs.length; ++i) {    if (configs[i].second_id) {        output_json[configs[i].second] = configs[i].second_id;    }}console.log(JSON.stringify(output_json));
Saving and loading parts of configuration
javascript;node.js;json;file