Google JavaScript Interview With A Frontend Engineer

  Рет қаралды 200,272

Clément Mihailescu

Clément Mihailescu

2 жыл бұрын

In this video, I conduct a mock Google JavaScript interview with a frontend engineer, Conner Ardman, who's also the FrontendExpert course creator and an ex-Facebook software engineer. As a Google Software Engineer, I interviewed dozens of candidates. This is exactly the type of frontend JavaScript coding interview that you would get at Google or any other big tech company.
Check out the React interview that we filmed on Conner's channel: • React Coding Interview...
AlgoExpert: www.algoexpert.io/clem
SystemsExpert: www.systemsexpert.io/clem
MLExpert: www.algoexpert.io/ml
FrontendExpert: www.frontendexpert.io/clem
ProgrammingExpert: www.programmingexpert.io/clem
My LinkedIn: / clementmihailescu
My Twitter: / clemmihai
My Instagram: / clement_mihailescu
Prepping for coding interviews or systems design interviews? Practice with hundreds of video explanations of popular interview questions and a full-fledged coding workspace on AlgoExpert - www.algoexpert.io - and use the promo code "clem" for a discount on the platform!

Пікірлер: 259
@clem
@clem Жыл бұрын
Be sure to check out the React interview that we filmed on Conner's channel! kzfaq.info/get/bejne/a96WZ8J83Z3Fqps.html
@PSSMPlay
@PSSMPlay Жыл бұрын
Hey Clement, your deepEquals function also does not work on all cases because the Object.keys() array is not ordered. Therefore you could have the same object {a: 1, b: 2} and {b: 2, a: 1} throwing false. The only wall to deepEqual objects is to use a Set and compare the size to both the object's keys and then iterate the set.
@gaurabsubedi3579
@gaurabsubedi3579 Жыл бұрын
Hey Clement, do I get the opportunity to have a mock interview with you on AlgoExpert?
@anshujindal3694
@anshujindal3694 Жыл бұрын
@@PSSMPlay I actually wrote the same comment and later found out your comment here 😅. I think I am not the only one who was able to come up with that bug 😂
@SportFusionYT
@SportFusionYT Жыл бұрын
deepEquals utility function was fun to watch. Though there is a failing test case. { a: 1, b: 2 } === { b: 2, a: 1 } should return true. Instead of checking equality of key arrays, we can do the following - for (let i in value1keys) { if (!value2keys.includes(value1keys[i])) { return false; } }
@ConnerArdman
@ConnerArdman Жыл бұрын
Thanks for having me back on! These questions were harder than they seemed 👀
@aman.social2100
@aman.social2100 Жыл бұрын
Especially the 2nd one 😅
@ManoToor
@ManoToor Жыл бұрын
Does your deepEquals work with functions or classes?
@thedevnoteyt
@thedevnoteyt Жыл бұрын
I have been doing JavaScript for last 9/10 months, after watching 8 mins of your video I realised that, still there are thousands of things to learn in JS. Going to re-learn the important concepts again 😅. It was kind of an eye opener for me. Thanks Clement 😉
@red_boum
@red_boum Жыл бұрын
Promises are usually more difficult for front-end devs because we only use (async await)
@UrbanJackJr
@UrbanJackJr Жыл бұрын
​@@red_boum but these are still promises under the hood.
@thalibmuhammad9519
@thalibmuhammad9519 Жыл бұрын
ive been doing javascript react for 5 years and i still have same feeling as you
@thedevnoteyt
@thedevnoteyt Жыл бұрын
@@thalibmuhammad9519 Thanks for your reply , it is giving me a little ray of hope ! 😅 Maybe I'm still at a very early stage of learning JS. It'll take time ig 😄
@thedevnoteyt
@thedevnoteyt Жыл бұрын
@@red_boum that's true 😅
@universecode1101
@universecode1101 Жыл бұрын
As a Js - React developer, I am always ready to see this type of content, because it is clean, it keeps me trained, I improve, and even fun 😜
@alexandrsachishin962
@alexandrsachishin962 Жыл бұрын
13:00 better approach is to use Number.isNaN() instead of isNaN() to check if a number is NaN. also this comparison might be simplified using Object.is(valueOne, valueTwo) which also works with NaN ( Object.is(NaN, NaN) )
@HarukiMiyazawi
@HarukiMiyazawi Жыл бұрын
After failing google on site and seeing Clement's amazing problem solving skills, it's clear to me why he got the job and I didn't. You're awesome dude!
@kelvinxg6754
@kelvinxg6754 Жыл бұрын
stay faithful brother keep up the work you'll get there.
@technologykid7041
@technologykid7041 Жыл бұрын
don't worry google is notorious for hard coding interviews, you got this! Stay motivated
@hovarda0655
@hovarda0655 Жыл бұрын
We are all gonna make it brah
@chrtravels
@chrtravels Жыл бұрын
I have been learning to code for a couple of years now and watched some of your videos back when you first launched Algoexpert. I hadn't looked at your website in some time and man is it super impressive. It has a clean and beautiful design. The curriculum and topics you cover is incredible. What an excellent business you have created. Bravo. I kind of wish I hadn't spent so much money to join a boot camp recently. I'd just go and learn everything you have on that site, build a few projects and call it a day! ;-)
@shaileshk_gy
@shaileshk_gy Жыл бұрын
Thanks for this. This actually helped me learn a lot of things I never knew.
@doublegdog
@doublegdog Жыл бұрын
Actually tried out algoexpert after seeing ads on youtube for over a year. Thought it wasn't anything special but the platform plus the blind75 leetcode questions really helped me out in landing a job at amazon!! Definitely recommend the platform although I wish I didn't have to pay a yearly subscription fee and instead had a monthly option. But still, i think even the yearly subscription is affordable enough.
@Nsiem12
@Nsiem12 Жыл бұрын
did you do the blind75 on algoexpert or do you mean the blind75 leetcode questions AND the algoexpert questions is what helped you?
@AWPNATiCTV
@AWPNATiCTV Жыл бұрын
To fix "problem" that you guys had at 12:00 with the isNaN function not returning what you would expect, you now (since es6) have the method Number.isNaN(), that only returns true if the value is actually NaN. The isNaN function returns unexpected values because it tries to convert the value to number and then check if it is NaN. Since strings that are not the empty string are coerced to NaN when converting to number, isNaN("some non-empty string") runs as isNaN(Number("some non-empty string")) == isNaN(NaN) == true. Number.isNaN checks if the value is of type number first and returns false if it is not, an then checks for NaN.
@howuseehim
@howuseehim Жыл бұрын
Where did you learn all of that 😃
@nekiro894
@nekiro894 Жыл бұрын
@@howuseehim in a book I believe, that's a great source. Javascript does all sort of blind conversions on values to ease equal checking
@SafetyLast-_-
@SafetyLast-_- Жыл бұрын
Exactly! I also wanted to write a similar comment about wierdness of isNaN(). And that Number.isNaN() is much more reliable in that type of checks :) Searched for this comment to not duplicate and if here it is! 👍
@gardelin4793
@gardelin4793 Жыл бұрын
@@howuseehim Probably in You don't know JS book
@howuseehim
@howuseehim Жыл бұрын
@@gardelin4793 thank you I will check it out
@AndrewTSq
@AndrewTSq Жыл бұрын
I did not think this video would give me so much, cause I am not so experienced in JS, but I actually understand how the functions works, and know the functions we use. So its fun to follow with this, and also learn what these functions do :)
@UnimpressedCat
@UnimpressedCat Жыл бұрын
Nice interview, the questions are quite practical and test the knowledge of the language. And damn, the interviewee is quite good at catching edge cases and clues from the interviewer
@TheDoubleMvp
@TheDoubleMvp 3 ай бұрын
Great questions, definitely representative of the sort of questions you'd be asked in a big tech FE interview. Conner did awesome as well, solving all 3 with clean code in < 1 hour in an interview would be an easy yes from me.
@canonicalbogdan
@canonicalbogdan Жыл бұрын
24:30 -> The order you get properties is a complex topic in JS. To have a general idea about it: Before ES5 there was no order defined for iterating objects. Here came ES2015 and there was a order defined in certain situations(Object.assign, JSON.parse, JSON.stringify, etc.) and the order followed this pattern: integer keys -> ascending order string keys -> insertion order symbols -> insertion order ES2020 came with changes for Object.keys, Object.entries, Object.values. In conclussion: if you had es2020 you could have used Object.entries for that. Peace
@Krzysiekoy
@Krzysiekoy Жыл бұрын
The deepEquals question reminded me of a similar problem in the Dan Abramov's Just Javascript "course" (it's not really a course, but I don't know how to describe it). Basically the problem was: "Write a function called strictEquals(a, b) that returns the same value as a === b. Your implementation must not use the === or !== operators." It was a fun problem, especially when you consider some details that are not super obvious, like 0 === -0 is true or NaN === NaN is false. Now, the deepEquals question seemed to be way more challenging and it was great watching Conner go through the problem.
@aaronmark3930
@aaronmark3930 Ай бұрын
use bit operators
@deepakjangid3872
@deepakjangid3872 Жыл бұрын
Today I had an interview and there we exactly these two promiseAll and object deepEquals, and now after the interview I am watching this.
@lucasrgsilva
@lucasrgsilva Жыл бұрын
For the 1st question you can actually use async await in a for...of loop, because all promises are in the pending state, doing that if the first one takes longer, the others will be completed when you reach them in the loop.
@covle9180
@covle9180 Жыл бұрын
Love this video! I think with the deepEquals function there were still 2 unsolved edge cases. (But I'm happy to he corrected) 1. The order of object.Keys isn't guaranteed to be sorted, so the deepEquals check to make sure the same keys exist could give a false negative. 2. You can get endless recursion when an object contains a nested reference to (part of) itself.
@valseedian
@valseedian Жыл бұрын
came here specifically to make these two points.
@unorevers7160
@unorevers7160 Жыл бұрын
100% correct
@nickrobinson6434
@nickrobinson6434 Жыл бұрын
The key order issue also caught my attention. The problem is, in JavaScript, key order is never guaranteed. The lodash isEqual function does not account for key order either. _.isEqual({ "a": 0, b: "1" }, { "b": 1 , "a": 0 }) returns true;
@GeekyAdarsh
@GeekyAdarsh Жыл бұрын
for #1 we can use hasOwnProperty method
@sadramohh
@sadramohh Жыл бұрын
About 1. Does the order really matter in objects? Two objects with exactly the same keys and same values for those keys behave exactly the same regardless of the order their properties were added. Is there a case where the order of keys is actually integral to a programs functionality? About 2. Totally agree.
@Endrit719
@Endrit719 Жыл бұрын
The fact that you caught the undefined case blew my mind, and in the updateTimer it fckin blew my mind again, I don't even understand why it is working
@farazcsk
@farazcsk Жыл бұрын
Great video! Would also love to see a standard algorithms/ds video but in JS
@sotam8938
@sotam8938 Жыл бұрын
agree!
@Ibrahim__123
@Ibrahim__123 Жыл бұрын
Just to add Object.entries() one can rely on the array it's return...I read about it just now while watching the interview ...Welldone guys....Super....
@clintondannolfo714
@clintondannolfo714 Жыл бұрын
I didn't watch the full video but perhaps the function "getTimer" could use "getter" methods on JS classes to always provide the most up to date value based on the current time, without having to use setInterval
@321123580
@321123580 Ай бұрын
Super helpful interview, thank you for the content
@starlingroot
@starlingroot Жыл бұрын
Quality content as always
@izyo8146
@izyo8146 Жыл бұрын
Hey Clement! Wanted to ask about the Big O for time for deepEquals, is that O(n) right? I'm currently taking a course for algo's and data structures and just wanted to ask you thattt
@bahadrtaspinar4575
@bahadrtaspinar4575 Жыл бұрын
my man getting faster in each video while promoting algoexpert
@ozzyfromspace
@ozzyfromspace Жыл бұрын
10/10, wonderful interview. Interviewee did really well imo
@anupmahato6163
@anupmahato6163 Жыл бұрын
Wonderful interview. @Corner Ardman I think one edge case is missed in PromiseAll problem , when you don't pass any promise to PromiseAll function.
@hicoop
@hicoop Жыл бұрын
Watching this video with the javascript console open and my mind completely blown
@anshujindal3694
@anshujindal3694 Жыл бұрын
I think deepEquals function would fail one edge case by doing the last change if obj1 = {b: 2, a: 1}; obj2 = {a: 1, b: 2}; because Object.keys() return the keys in insertion order and upon calling deepEquals again, it would be ['a', 'b'] and ['b', 'a'] and it would get failed while checking if 2 arrays are equal or not and in actual library it would return true.
@jordanbarone9094
@jordanbarone9094 Жыл бұрын
New JS developer (about 6 months) looking for an entry level position...after watching this, I am now extremely scared for an interview lol...Very intimidating! Great video though!
@timmoser7093
@timmoser7093 Жыл бұрын
At 37:50, if you run deepEquals on the keys too, it would return false on two objects with the same entries but in different order or am I missing something?
@user-wu2ck9jo1l
@user-wu2ck9jo1l Жыл бұрын
Thank you for the video, I learnt a lot. However, I think there is an edge case for the second question, lets say : const obj1 = { a: undefined , b: 2} const obj2 = { b: 2 , a: undefined } with this code the output of deepEquals (obj1 , obj2 ) will be false. whereas it should be "true" I think instead of deepEquals (valueOneKeys, valueTwoKeys) in line 31, a better approach would be to iterate through valueOneKeys and if the item was not found in the valueTwoKeys then return false. for (let i=0; i < valueOneKeys.length ; i++){ if ( valueTwoKeys.findIndex (element => valueOneKeys[i] === element) === -1 ) return false }
@dmytrochornyi5249
@dmytrochornyi5249 Жыл бұрын
For the second problem, just compare the types first and then compare JSON.stringify of two values, not sure about speed, but covers most of the cases
@dontbetoxic4387
@dontbetoxic4387 Жыл бұрын
thats what i thought too
@kubrd1921
@kubrd1921 4 ай бұрын
JSON.stringify is sensitive to the order of properties in objects. If two objects have the same properties and values but in a different order, they will be considered unequal.
@unorevers7160
@unorevers7160 Жыл бұрын
Im pretty proud that I spottet the edgecase where the value 'undefined' of an object is compared to the undefined value of an unfound key in the array that was compared against. Then again while I thought about comparing 'undefined' I forgot about how JavaScript also has 'null' objects :'D
@yanwei6677
@yanwei6677 Жыл бұрын
Great video For the 2nd question, we compare objects based on ValueOne's keys. And if we compare them again on ValueTwo's keys but not deepEquals(keys1, keys2) like the video did, will it work? I believe not, it will failed by this case: {a: undefined, b: "str"} {b: "str", c: undefined}
@somnathnavale9120
@somnathnavale9120 Жыл бұрын
for second question we can use another approach like serialized both the inputs using JSON.stringify() then make strict comparision """ let a1=JSON.stringify(input1) let a2=JSON.stringify(input2) if(a1===a2){ console.log('they are deep equal'); }else{ console.log('they are not equal'); } """ using recursion """ function deepEqual(obj1,obj2){ if(typeof obj1===typeof obj2 && typeof obj1!=='object'){ return obj1===obj2; } if(typeof obj1!==typeof obj2){ return "can't compare different types" } if(!Array.isArray(obj1) && Object.keys(obj1).length!==Object.keys(obj2).length){ return false; }else if(obj1.length!==onj2.length){ return false; } let ans=true; for(let key in obj1){ ans=ans && deepEqual(obj1[key],obj2[key]); } return ans; } """ comment if I made any mistake or not added any edge case
@Kay8B
@Kay8B Жыл бұрын
The problem is objects order can be all over the place, once you stringify it the order is locked and although two objects maybe equal the order isn't and returns false but its technically true.
@BGivo
@BGivo Жыл бұрын
That was sick.. I didn't realize Clement was so good holy jesus
@shriharikulkarni3986
@shriharikulkarni3986 Жыл бұрын
Hi Clement, whenever interview date is near, i get stressed, i don't know how to revise, and always in my mind I'll be like preparation is not enough, and if you write a program and test cases are not fully accepted, lot of nervousness starts which will impact during the interview. How to actually stay mentally when the interview is near?
@msx47_
@msx47_ Жыл бұрын
You didn't need it but to check for object you can use something like myVar.constructor === Object or for array with myVar.constructor === Array.
@michaelschaaf1155
@michaelschaaf1155 Жыл бұрын
such good content. keep it goin
@mstalcup
@mstalcup Жыл бұрын
The problem with using isNaN() is that it forcefully converts the passed parameter to a number before evaluating it. A better way to check for equality is to use Number.isNaN(). This returns true only if the parameter is of type number and actually equates to NaN.
@nivelis91
@nivelis91 Жыл бұрын
21:00 you could use an XOR "^" operator instead of OR "||" :) You also forgot about 0, -0, Infinity and -Infinity - but it's arbitrary whether they're treated equal or not. "===" will say yes, Object.is() will say no. Aaaand there are functions too ;)
@aaronmark3930
@aaronmark3930 Ай бұрын
was thinking the same with xor, but since he checked a === b before the || call, it doesn't matter to use xor or not
@keirangrant3706
@keirangrant3706 Жыл бұрын
As a 25 year old who just started learning to code, this made my brain hurt 😂
@thehierophant1314
@thehierophant1314 Жыл бұрын
I just realized that coding logic is so hard because the interviewer also has to understand what the guy is doing 🤭 when he asks him questions and then he says, “oh okay I see!”
@fiphee7776
@fiphee7776 Жыл бұрын
I'm new with JS but for the first problem shouldn't the slowPromise be at any position other than last position in the input promises array for it the be a useful test?
@jesseliverless9811
@jesseliverless9811 Жыл бұрын
12:12 isNaN(x) returns if the value of x is 'NaN', *after conversion*. So in your example, isNaN('aaa') returns true, because of course it is, the string 'aaa' is not a number, so there's no problem here. The quirk is when you test isNaN(" "), it returns false, because it converts " " (or "") to 0, which is a number, so isNaN(0)=false. Same goes for strings that get interpreted as numbers, so isNaN("3") ==> isNaN(3) ==> false. This behaviour might be unexpected if you're unaware of the implicit conversion.
@carmeloramirez9559
@carmeloramirez9559 Жыл бұрын
amazing your content.
@grablecdub
@grablecdub Жыл бұрын
Love these
@MrKanthappu
@MrKanthappu Жыл бұрын
He didn’t apply for google and you aren’t interviewing for google. So stop saying google interview
@akshaysharma30498
@akshaysharma30498 3 ай бұрын
For checking between array and object, woouldn't checking if 'length' property exists on one and not on another work ?
@ScorpioneOrzion
@ScorpioneOrzion Жыл бұрын
For that of deepEquals their is one situation missing const obj1 = {a:1, b:2}; const obj2 = {b:2, a:1}; console.log(deepEquals(obj1, obj2));
@user-ef3ez1lf2n
@user-ef3ez1lf2n Жыл бұрын
If you rely on order, than JSON.stringify(a) === JSON.stringify(b), in other cases, just use lodash )))
@felixc.programs8209
@felixc.programs8209 Жыл бұрын
Good video as always! You motivated me to start my own Data Science/Engineering KZfaq channel myself. Can't wait for your future content!
@McScraych
@McScraych 5 ай бұрын
Regarding the second task. Why check arrays separately? (I think that the "Object" code worked properly for the arrays). Why didn't write tests for all the types? Also what regarding different class instances?
@giorgioolivero3002
@giorgioolivero3002 Жыл бұрын
I have a questioni about the google interview: I heard in a video that you used angular as a front-end engineer, the question is this: should I learn that before trying to get into Google? My plan was to learn to use react instead
@melanineyedoc
@melanineyedoc Жыл бұрын
I got an algoexpert ad on this, with algogirl too!!!!!
@barefeg
@barefeg Жыл бұрын
Does the second solution work for objects with keys in different orders?
@nayeemurrehman4922
@nayeemurrehman4922 Жыл бұрын
This is awesome 💝
@goktugerol1127
@goktugerol1127 Жыл бұрын
They take you to the technical interview in the first meeting or they do that after the first meeting? I have a meeting soon but the recruiter didn't mention anything about technical interviews etc, they said they wanna meet me.
@modex98
@modex98 Жыл бұрын
there still a problem in the second function ==> the edge case where we have to objects with same keys but the keys are in different order
@shaikzuhair8537
@shaikzuhair8537 Жыл бұрын
Good work 👍
@Paladin-ev1gg
@Paladin-ev1gg 27 күн бұрын
Hello. What type of "seniority" are these qeustions? As someone who's looking for a first job in coding this seems difficult.
@miguelpancada5873
@miguelpancada5873 Жыл бұрын
Isn't there a concurrency bug on the promiseAll function? If promises run asynchronous, when they want to increment settledPromisedCounter, it´s possible to get a Phantom/Ghost update because settledPromisedCounter is not threadsafe, right? If 2 promises read at the same time settledPromisedCounter, they will read the same value, lets say 0, and each of them will increment to 1.
@DK-pf2dg
@DK-pf2dg Жыл бұрын
More of these!!!!
@Krilllind
@Krilllind Жыл бұрын
For the `updateTimer` function I miss a discussion regarding time drift when using setTimeout. This HTTP 203 episode (kzfaq.info/get/bejne/g6mZaaSLstHck4k.html) talks about how to optimize for drift. Otherwise, good episode! One thought, could you not make use of `setInterval` as well in the sandbox area? And use a `clearInterval` with `setTimout` to perfom cleanup?
@yechielvizel
@yechielvizel Жыл бұрын
I thought about the undefined edge case the second he said “will give you undefined”
@alejandrobaezarcila1537
@alejandrobaezarcila1537 Жыл бұрын
very good content
@YoriDj
@YoriDj Жыл бұрын
I want to see the center a div interview with a frontend engineer
@anthonywalker6168
@anthonywalker6168 Жыл бұрын
Google has turned into an ad search engine. When I search for something, I don’t want to be followed around my a man ad. Definitely investing in an ad blocker
@azimb2280
@azimb2280 Жыл бұрын
Where we will get that job vacancy as react fe in google ? Ive never found job as fe in google
@coding99
@coding99 Жыл бұрын
Awesome!
@ChintanPatel
@ChintanPatel Жыл бұрын
for object compare we can change it to JSON string and compare ?
@osazi
@osazi Жыл бұрын
26:58 if you had two objects with the same number of key but in different order wouldn’t that technically be true according to your your logic ? I might be wrong but if you have two objects and their keys are in different order but the values are the same, are they then the same object?
@Kay8B
@Kay8B Жыл бұрын
Depends on what your after, they are not the exact same object allocated on memory etc but they are equal.
@mag2XYZ
@mag2XYZ Жыл бұрын
The first one is not correct, as one can add elements to the array while the Promises are running, which makes the condition to exit impossible. It can be fixed by storing the starting length of the array in a variable at the beginning of the function.
@rnater7145
@rnater7145 Жыл бұрын
Symbols are possibly another edge case
@kuti1643
@kuti1643 Жыл бұрын
deepEquals could work with a one-liner return JSON.stringify(valueA) === JSON.stringify(valueB); Wouldn't that be an acceptable solution? Is there a catch to that? I've also checked with all the test cases and it works for me.
@faruqkhan5035
@faruqkhan5035 Жыл бұрын
As a Js - React developer is it required Hard DSA to get a job in google ?
@HeinekenLasse
@HeinekenLasse Жыл бұрын
38:00 - Don't you need to sort the keys to run a deepEquals on them ?
@arifozturk5972
@arifozturk5972 Жыл бұрын
For the second question, wouldn't it have been way easier to stringify the objects and then check the strings and the types match? I.e. JSON.strinigify and typeof equality
@JosueAdeLima
@JosueAdeLima 6 ай бұрын
I was thinking in some sort of binary check but not possible in JS, I think you are totally right!
@RodLewis1
@RodLewis1 Жыл бұрын
Love the content, nice work guys. Would this work for the deep compare question or am I missing an edge case? const deepCompare = (a, b) => { let aString = JSON.stringify(a, null, 2) let bString = JSON.stringify(b, null, 2) return aString === bString }
@vishmaychauhan2863
@vishmaychauhan2863 Жыл бұрын
if the order of elements in 2 objects are not same, then it would return false. Hence it wouldn't work ig. Correct me if I'm wrong
@merlin6962
@merlin6962 Жыл бұрын
I think it produces the correct result, but in a tech interview it wouldn't be a good solution. The interviewers want to see you implement the algorithm and explain your thoughts, not take a short cut. You could obviously mention that this would be an easy solution as well. Additionally this solution will be quite inefficient for large objects, both CPU and memory wise.
@RodLewis1
@RodLewis1 Жыл бұрын
@@vishmaychauhan2863 you are correct, unfortunately I can only come up with a far less elequant solution in that case 🙃 const isObject = obj => typeof obj === 'object' && !Array.isArray(obj) && obj !== null; const flattenObjectToArray = (obj, parent, flatObj = {}) => { Object.keys(obj).forEach(key => { let next = parent ? parent + '.' + key : key; if (typeof obj[key] === 'object') { flattenObjectToArray(obj[key], next, flatObj); } else { flatObj[next] = obj[key]; } }) return Object.entries(flatObj).sort(); } const flattenAndSortArray = arr => arr.flatMap(x => isObject(x) ? flattenObjectToArray(x) : [x]).sort(); const handleObjectType = (x) => isObject(x) ? flattenObjectToArray(x) : flattenAndSortArray(x); const deepCompare = (a, b) => { let typeofA = typeof a let typeofB = typeof b if (typeofA !== typeofB) return false; if(typeofA === "object") a = handleObjectType(a) if(typeofB === "object") b = handleObjectType(b) let aString = JSON.stringify(a, null, 2) let bString = JSON.stringify(b, null, 2) return aString === bString }
@vishmaychauhan2863
@vishmaychauhan2863 Жыл бұрын
@@RodLewis1 there's nothing less elequant, if it works, it works lol.
@MoulikAdak
@MoulikAdak Жыл бұрын
Noobs. Functions aren't handled.
@omgItsGreg
@omgItsGreg Жыл бұрын
In the first solution, you said that it's fine to use native javascript code. Then why the heck would you not just use Promise.all? There's also an issue with this solution, if multiple promises reject. You can't call the reject function multiple times.
@dziq4549
@dziq4549 Жыл бұрын
After checking primitive values and arrays, wouldn't JSON.stringify(valueOne) === JSON.stringify(valueTwo)? I mean when we are sure these two are objects.
@pranavyeole102
@pranavyeole102 Жыл бұрын
Hi Clément, can we get the prices of Algoexpert products in Indian rupees and an option to purchase the product with UPI (widely popular in India). Algoexpert is getting a lot of consideration from engineering students here, and making these changes will make Algoexpert a lot more accessible to Indian students. Please do consider this request 🙏🏼
@kumarsamaksha7207
@kumarsamaksha7207 Жыл бұрын
Just pay using card
@Daneus_GMD
@Daneus_GMD Жыл бұрын
34:36 my head almost exploded here
@mkurshumov
@mkurshumov Жыл бұрын
Why not use JSON.stringify(valueOne) === JSON.stringify(valueTwo) for comparing non-primitive values
@jpborges
@jpborges Жыл бұрын
If we are going down that route, might as well stringify both objects and return in one line
@kilyos9212
@kilyos9212 Жыл бұрын
It looks like the first one is incorrect for two reasons. It will hang forever on an empty array, and it will allow doubly rejected promises. Maybe I'm wrong tho. Good work Conner.
@nahfamimgood
@nahfamimgood Жыл бұрын
so has FANG stopped doing leetcode algorithm style questions for FE positions?
@AlexWardi
@AlexWardi Жыл бұрын
Looks like they've moved on to making people implement non-optimized browser functionality instead. Also silly, imo
@rezaroohian9549
@rezaroohian9549 Жыл бұрын
There's a bug in promiseAll code. If a promise gets rejected we should still wait for all promises to finish since there's no way to cancel them after calling then on them.
@goodrowj
@goodrowj Жыл бұрын
You guys forgot the case of either object being a function in deepEquals
@programacaosimplicada
@programacaosimplicada 10 күн бұрын
1:59am and I'm watching google interviews. Rethinking my life choices...
@AshwinMothilal
@AshwinMothilal Ай бұрын
This was a good interview, but one confusion is, MDN says should be . Here it's . Probably might need to correct it.
@conceptualhandle
@conceptualhandle Жыл бұрын
You forgot to sort the keys before passing them to deep equals.
@leeboyin945
@leeboyin945 Жыл бұрын
1:22 promiseAll 9:12 deepEquals 38:30 getTimer Great demo, learned a lot of tricky JS edge cases in this video! Thanks I think people are just unlikely able to remember all those weird parts of JavaScript. It is JavaScript that need improved, not developers. 🤔
@feignit
@feignit 3 ай бұрын
3rd question was really stupid, basically using an anti pattern.
@miguelpuentes9643
@miguelpuentes9643 Жыл бұрын
Next time can you make the font bigger , please
@thekwoka4707
@thekwoka4707 Жыл бұрын
For the second, why did it not just start with a strict equals check? Surely if they are strictly equal, then they are deeply equal too.
@senturkdev
@senturkdev Жыл бұрын
Sir, do you have a plan for regional price? I live in Turkey and your plans are almost 600-700 Turkish liras. The amount is really high for people who live in Turkey. 🙏🏻
@vulcs
@vulcs Жыл бұрын
that is super easy - try instead to ask them to write a rollup plugin
@giovannyalbarracin1141
@giovannyalbarracin1141 Жыл бұрын
Why didn't he use promise allsettled method in the first exercise?
@shakedbukai8079
@shakedbukai8079 Жыл бұрын
would u count this as a junior interview or a senior interview?
@GeekyAdarsh
@GeekyAdarsh Жыл бұрын
I would definitely say not junior, more like mid/senior
Google Coding Interview With A Facebook Software Engineer
49:59
Clément Mihailescu
Рет қаралды 919 М.
Beginner React.js Coding Interview (ft. Clément Mihailescu)
36:31
Ben Awad
Рет қаралды 2,1 МЛН
КАКОЙ ВАШ ЛЮБИМЫЙ ЦВЕТ?😍 #game #shorts
00:17
Разбудила маму🙀@KOTVITSKY TG:👉🏼great_hustle
00:11
МишАня
Рет қаралды 3,9 МЛН
Uma Ki Super Power To Dekho 😂
00:15
Uma Bai
Рет қаралды 60 МЛН
Google Frontend Interview With A Frontend Expert
47:59
Clément Mihailescu
Рет қаралды 1 МЛН
Medium Google Coding Interview With Ben Awad
51:27
Clément Mihailescu
Рет қаралды 1,2 МЛН
Everything You Need To Know About Being A Blockchain Engineer
17:21
Clément Mihailescu
Рет қаралды 18 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
Ex-Google Software Engineer Speeds Through 3 Coding Interview Problems
59:23
Clément Mihailescu
Рет қаралды 101 М.
Easy Google Coding Interview With Ben Awad
28:00
Clément Mihailescu
Рет қаралды 994 М.
Google Coding Interview With A College Student
59:57
Clément Mihailescu
Рет қаралды 1,5 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 1,9 МЛН
Apple watch hidden camera
0:34
_vector_
Рет қаралды 48 МЛН
A Comprehensive Guide to Using Zoyya Tools for Photo Editing
0:50