• Recursively flatten a nested object, while maintaining key structure

    Parameters

    • obj: any

      Object to flatten

    • Optionalparent: any

      Recursively check if key is a parent key or not

    • result: any = {}

      Result

    Returns any

    • Flattened object
    const car = {honda: {model: "Civic"}};
    console.log(flattenObj(car)); //Output {honda.model: "Civic"}