Q4 Flatten Deeply Nested Object | Adobe Frontend Interview Questions | Javascript Questions

preview_player
Показать описание
Important Playlists to crack Frontend Interviews 👇🏻

For any doubts and help follow me on:

Track: Clarx, Debris, 3rd Prototype, Castion, EMDI - Evolution (feat. Harley Bird) [NCS10 Release]
Music provided by NoCopyrightSounds.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Tags and hashtags:
#javascript #javascriptinterviewquestions #JS #js #frontend #frontendDeveloper #software #developer #engineer #softwareengineer #frontendengineer #OOPS #closures #salary #job #placement

Javascript concepts
JS OOPS
Javascript Object Oriented Programming
How OOPS works in Javascript
Prototypes in JS
Javascript __ptoto__
What is a prototype in Javascript
Basics of JS
How to learn javascript
Javascript
Javascript concepts
Frontend Engineer
Frontend Developer
Software Engineer
Software Development Engineer
How to become a frontend engineer
How much salary does a frontend developer make
What is the salary of a frontend engineer
Javascript for a frontend developer
Concepts of javascript
Bootcamp for frontend developers
Roadmap for a frontend engineer
How to get a job as a frontend engineer
How to become a frontend developer
Javascript tutorial
Javascript full course
Javascri[t interview questions
Javascri[t interview questions and answers
Salary of a frontend developer
System Design
Frontend System Design
Рекомендации по теме
Комментарии
Автор

How can we optimise the complexity of this also since browser has limited memory to execute and this code may fail in case of thousands of nested levels

shagunpreetsingh
Автор

Hi Vedant, can we solve this question in below mentioned way :

function flattenObj(obj, parentKey=""){
let finalObj = {};
for(let key in obj){
const newKey = parentKey + key;
const value = obj[key];
if(typeof value === 'object') {
let flatVal = flattenObj(obj[key], (newKey + "."));
finalObj = {...finalObj, ...flatVal};
}
else finalObj[newKey] = value;
}
return finalObj;
}

I have doubt for optimization bcz we are creating a new object on each recursive call, but it will garbage collected once the call ends. Please review this.

jayantsharma
Автор

We want polyfill for map, reduce, filter

varun
Автор

const delimiter = "_";

function flatten(obj) {
const result = {};
Object.keys(obj).forEach(key => {
const value = obj[key];
if(typeof value === "object") {
const temp = flatten(value);
=> {
= temp[tempKey];
})

} else {
result[key] = value;
}
})
return result;
}

devendrapandey
Автор

output Im getting as {} ? anyone else getting the same?
function flatenObject(obj, parent){
const finalObj={}
const generateFlatObject = (obj, parent)=>{
for(let key in obj){
const newprent = parent + key ;
const value=obj[key];
if(typeof value === "object"){
generateFlatObject(value, newprent+".")

}

}

}
generateFlatObject(obj, parent)
return finalObj
}
let obj = {
A: "12",
B: 23,
C: {
P: 23,
O: {
L: 56
},
Q: [1, 2]
}
}
console.log(flatenObject(obj, " "))

roidondsouza
Автор

teach single language... don't mix up hindi and english... suddenly we can't understand

muruganpaneerselvam
welcome to shbcf.ru