Frontend Interview Question | How to Flatten Array of Array ? | Recursion| Javascript Interview

  Рет қаралды 14,485

Nisha Singla

Nisha Singla

Күн бұрын

Hi Everyone
Flatten Array of Array is one of the most asked Interview Question and this is very important to understand to solve many complex problems in programming.
This video will cover all about how to Flatten your array of array and how Recursion will help you to solve this use case.
Watch the complete video till the end to understand it completely.
What is Recursion?
Recursion is defined as the process of a function calling itself. A recursive function is the function that corresponds to this.
The base case (or halting condition) and the recursive call to itself are commonly two elements of a recursive function.
The base case is when the function should no longer recurse.'
A recursive call is when a function calls itself, usually with slightly modified arguments that 'work down' to the base case.
Check video on Recursion
• What is Recursion | Ja...
Support my channel by liking and sharing my videos so that I can reach to wider audience. Please share it in your network 🙏
Connect with me on social platform:
Facebook: / angularjs4beginners
LinkedIn: / nisha-singla-82407aa0
Instagram : / nishasingla05
Twitter: / nishasingla05
For more such interesting videos, please subscribe to my channel and stay connected.
#FlattenArray #frontEndInterview #JavascriptInterview

Пікірлер: 55
@MrCoder-u9y
@MrCoder-u9y Жыл бұрын
Surely your teachers must be proud of you, best explained!
@pinakapani8250
@pinakapani8250 Жыл бұрын
I am really addicted to your videos after watching your redux toolkit in 1 hour Project and now I am exploring all of your videos and every video is a diamond. Thank you for your excellent explanation & hoping to learn a lot from you mam.
@ajithkumarb8216
@ajithkumarb8216 2 жыл бұрын
Clearly explained. Thank you... expecting more interview questions from u
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@explore-learn-share6937
@explore-learn-share6937 2 жыл бұрын
Very well explained ✓ Concept of flate Ning array is clear to me now 🙏
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@shantanushukla1178
@shantanushukla1178 4 ай бұрын
Thank You so much ma'am, you are really very good teacher.
@mehakjain5384
@mehakjain5384 2 жыл бұрын
Thank you for explaining so effortlessly ☺️ good wishes to you ❤️
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you so much 🎉🥰🥰
@BrijeshSingh-dp1ku
@BrijeshSingh-dp1ku 2 жыл бұрын
Thanks for sharing keep making such tutorials 👍
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@srinivasamg2739
@srinivasamg2739 2 жыл бұрын
Nice explanation
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@vaibhavsarode6637
@vaibhavsarode6637 2 жыл бұрын
Osm and perfect explanation, thank you for the video
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@softwarejobkosam7327
@softwarejobkosam7327 2 жыл бұрын
Very helpful do more interview and in depth concept videos s
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@rosonerri-faithful
@rosonerri-faithful 2 жыл бұрын
Thanks Mam for the explanation.😃
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@shivugg
@shivugg 2 жыл бұрын
Wow madam you have repository of knowledge
@ashishnayak2666
@ashishnayak2666 2 жыл бұрын
Nice explanation....waiting for ur react series
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@malayaprasadlenka9088
@malayaprasadlenka9088 2 жыл бұрын
Nice explained 👍
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@ishaikhmd
@ishaikhmd 2 жыл бұрын
Excellent
@anandagar2k
@anandagar2k Жыл бұрын
should create the output variable inside the flatten function Try this : const arr = [[1,2],[3],4,6,[7,8],9,10]; function flattern(arr){ return arr.reduce((array,val)=>{ return array.concat(Array.isArray(val)?flattern(val):val); },[]); } console.log(flattern(arr));
@manpreetjord1885
@manpreetjord1885 2 ай бұрын
Nice solution
@prasankumar4306
@prasankumar4306 Жыл бұрын
Nice videos please do more
@harish1015
@harish1015 2 жыл бұрын
Hii Nisha, Make videos about patterns nisha
@saurabhkawatra8938
@saurabhkawatra8938 2 жыл бұрын
Amazing 👍🏻👍🏻👍🏻 mam could also tell about '... ' how to use this 3 dots
@NishaSingla
@NishaSingla 2 жыл бұрын
Please checkout my Javascript playlist. I have added Spread topic kzbin.info/www/bejne/h6vafIFnqLaha7s
@devloperadda1350
@devloperadda1350 2 жыл бұрын
Thank you 🙏
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
@niteshparmar9019
@niteshparmar9019 2 жыл бұрын
More simple way is arr.flat(arr.length) Or arr.flat(2)
@decadewgame9802
@decadewgame9802 2 жыл бұрын
sometimes flat methods is not allowed
@niteshparmar9019
@niteshparmar9019 2 жыл бұрын
@@decadewgame9802 JS as an evolving language giving us new features every year and almost every langauge is making itself better day by day. We should be aware and also be using the new things a langauge offers, that's my point. And at the end it only matters you did the task.
@swastikupadhye9291
@swastikupadhye9291 2 жыл бұрын
Cant we use flat method specifying depth...
@NishaSingla
@NishaSingla 2 жыл бұрын
We can use that, but all browser doesn't support yet and it always good to know your own implementation, as when you will some custom requirements than you might need to write your own implementation
@swastikupadhye9291
@swastikupadhye9291 2 жыл бұрын
Yes, you are right, implementing your own logic in the native JS is way better.
@dharmaraopalli6800
@dharmaraopalli6800 2 жыл бұрын
Hi Nisha can we do the recursion for brackets also like {{{}}{}}{}. I want to arrange it in an order .if yes please explain in one class
@karthikeyanjagan7832
@karthikeyanjagan7832 2 жыл бұрын
Hi Nisha Please explain Closure
@NishaSingla
@NishaSingla 2 жыл бұрын
I have added video on Closures too, checkout the playlist
@sunilkumar-zf4dx
@sunilkumar-zf4dx 8 ай бұрын
function flat(arr){ let output=[]; console.log(output) for(const ele of arr){ if(Array.isArray(ele)){ output= [...output,...flat(ele)] } else{ output.push(ele) } } return output; } console.log(flat([1,[2,[3],4],5]));
@josygeorge3115
@josygeorge3115 7 ай бұрын
it creates a string as the result, but not an array. doesn't solve the purpose...
@gyanendrarana3941
@gyanendrarana3941 2 жыл бұрын
The output is not flattered array, it is string.
@NishaSingla
@NishaSingla 2 жыл бұрын
We have flattened our array only
@AhmedMohamed-cf9dd
@AhmedMohamed-cf9dd 2 жыл бұрын
all of this code just write arr.flat(Infinity)!
@raz0229
@raz0229 2 жыл бұрын
The question states writing your own algorithm
@AhmedMohamed-cf9dd
@AhmedMohamed-cf9dd 2 жыл бұрын
@@raz0229 no it didn't
@NishaSingla
@NishaSingla 2 жыл бұрын
@@AhmedMohamed-cf9dd We can use that, but all browser doesn't support yet and it always good to know your own implementation, as when you will some custom requirements than you might need to write your own implementation
@sdwvit
@sdwvit 2 жыл бұрын
arr.flatMap(), you are welcome!
@AhmedMohamed-cf9dd
@AhmedMohamed-cf9dd 2 жыл бұрын
Or arr.flat(Infinity)!
@MrCoder-u9y
@MrCoder-u9y Жыл бұрын
Brother she explained the logic behind it!
@myvue4587
@myvue4587 2 жыл бұрын
Thank you 🙏
@NishaSingla
@NishaSingla 2 жыл бұрын
Thank you :)
What is Recursion | Javascript | Real World Examples
26:35
Nisha Singla
Рет қаралды 13 М.
The joker favorite#joker  #shorts
00:15
Untitled Joker
Рет қаралды 18 МЛН
The CUTEST flower girl on YouTube (2019-2024)
00:10
Hungry FAM
Рет қаралды 55 МЛН
Flatten Nested Arrays with Recursion in JavaScript
10:35
J.C. Hiatt
Рет қаралды 6 М.
Flatten an array - frontend/Javascript Interview Question
7:43
Interview.Js
Рет қаралды 13 М.
Whiteboard Coding Interviews: 6 Steps to Solve Any Problem
15:18
Fullstack Academy
Рет қаралды 370 М.
Google Frontend Interview With A Frontend Expert
47:59
Clément Mihailescu
Рет қаралды 1 МЛН