Get All Object Keys in nested complex Object

PHOTO EMBED

Mon Nov 21 2022 17:38:22 GMT+0000 (Coordinated Universal Time)

Saved by @AZbrahim

const data = {
  en: {
    text: "this text",
    title: "this title",
    person: {
      tale:"22cm",
      weight:"3kg",

    }
  }
}
const keyify = (obj, prefix = '') => 
  Object.keys(obj).reduce((res, el) => {
    if( Array.isArray(obj[el]) ) {
      return res;
    } else if( typeof obj[el] === 'object' && obj[el] !== null ) {
      return [...res, ...keyify(obj[el], prefix + el + '.')];
    }
    return [...res, prefix + el];
  }, []);


  
const output = keyify(data);

console.log(output);
content_copyCOPY