JavaScript Mock Interview | Interview Questions for Senior JavaScript Developers | Part 1
71.39k views3961 WordsCopy TextShare
Turing
The ninth chapter of the Turing Mock Interview series takes a look at what the technical interview f...
Video Transcript:
[Music] hello everyone welcome back to another round of during mock interview cities i'm jose technica tutting and i'm from montreal canada and at tutting i work on hiring the best engineers by helping them with the vetting process i have more than 17 years of experience and my expertise lies in javascript today i will be interviewing lao for the role of an experienced javascript developer and if you go for any javascript text text you might be passing by this interview okay view js node. js angular react yes before then you have a javascript interview okay so uh let's hear from you now uh could you please tell me a little bit more about your background about your professional experience yeah sure josie so regarding my professional experience i have been working with javascript from last four or four and a half years and like in the though in that experience i have been working with the uh companies uh i started my career in a local company where i was working with javascript frameworks like node. js sjs next years i have worked on front-end libraries like create.
js as well and with that uh after like couple of years i realized that i should go ahead and start freelancing and like with in freelancing i have worked on numerous projects with a number of clients uh where i've been building the different kind of dashboards or let's say their products which are like website builders and different kind of uh their products which help them in predicting their sales or increasing the revenue nice okay so i see how you have been working hard okay and to until today um so could you please tell me uh just a little bit more about some interesting javascript project that you have to work on yeah sure so regarding the interesting project i have worked for me it was a website builder which i have worked for one of my clients where we were providing an experience where users can just go ahead and drag and drop some elements whichever they want and that will just allow them to create the website website they want and like we are also providing them for deployment process so they can just hit a button assign the domain and they will be good to go and apart from that the other product product that i have worked on was a kind of inventory management system where the system was designed to predict the future sales for like the next quarter or next year so that company can decide how how should and how much they should be producing for that particular products because sales are depending upon the like market conditions and let's say if there is no sales there is no need for more production so i've been involved in those kind of projects moreover and like apart from that i have worked on different kind of dashboards that just shows different charts and stats to the companies so that they can decide how they want to proceed further nice nice really nice and just a quick question before we move on okay so in that projects okay did you use any framework and library javascript or it was uh vanilla javascript no uh for like website builder we we were using one stack basically express yet note servers and apart from that before the other projects i have been responsible for the front-end development where i was mostly uh using uh reaches as a development uh development environment and apart from that like different ui libraries like material ui and design delving and some other ui libraries like chakra uh like we were using those nice cool so thanks for sharing by the way okay so let's now move forward go to the javascript question okay and my first question for you is each javascript single thread or mood's writing javascript is a single threaded so yeah basically when whenever like you execute your code it is executed in sequence and it doesn't execute in a parallel manner so whatever operations you are doing that will be executed in a sequential manner correct nice and okay so javascript is single thread correct uh but how does javascript handle asynchronous operation like promises timers uh set amounts how how those obviously you can do that that we have the event loop so basically uh whenever you are executing those kind of asynchronous operations uh javascript maintains a call stack where all the calls you have made for different kind of functions or operations they are maintained and as soon as a particular function is finished it is popped from that particular call stack and where if in the meantime a new function comes in it pushes it into the call stack and uh javascript maintains event queue so whenever let's say you are executing uh an asynchronous code and you have to uh like once that code is finished eventually next callback that is given to the call stack so that you will have your asynchronous code executed and in the meantime your next lines of code will keep exhibiting nice good answer uh but i'm curious about something so you mentioned we have the code stack and we have the browse apis we have uh the event queues right so uh how javascript knows that promises uh ended and to execute the callback sorry can you repeat yes how does javascript knows okay that the promises uh just finish or set them out is ready to push in the corset okay for set timeout we basically use the timers so that like you have the second argument as a timer which you decide how long that particular function needs to wait before getting executed so basically as soon as you create your set timeout function trigger it just creates a delay before that particular function call and whenever you are uh going to execute a synchronous code with promise promises have like three states uh basically fulfilled uh if program is rejected or settled or not so basically based on those states uh javascript decides like which uh callback function to execute at that point nice okay we are going we are going back to promising later in this video so uh what do you understand about the event loop in javascript what's the event look event loop is basically let's say you have a couple of tasks ongoing so for each start you will have different kind of subtasks so uh while you are executing your particular task uh as soon as the subtasks come in uh javascript just pushes it into the call stack it just keeps executing the next uh function calls and after that it will just uh keep with moving uh let's say if a function call has four uh sub functions calls so call stack has those four functions pushed in uh as soon as those functions are getting uh executed and finished uh call stack pops out those functions and event queue just keeps uh registering those functions so that like it has all the what we see all the execute execution details and whenever let's say a function is finished eventually response backs to a call stack so that it executes the next relative function which is required to run nice just to adding something on its case so the event loop is the one that's keep checking the event queue so if you reserve a promise or a set amount for example you will push an event into the event queue and the event loop is the one that keep constantly checking the event kills so if there is any call back there some call back there the event loop will get there go back and push in the call stack then javascript will execute and we have several priorities for that okay so promises will resolve in the current execution of the event loop uh timers like set them out set immediate process next stick they all goes to the next loop which means is if you have uh 10 promises 10 promises will resolve uh will be pushed first in the call stack then a single set them out if you have a thousands of promises resolve it thousands of promise results will go to the call stack and then after that the first set timeout will go to the cost deck sounds good nice man so now we're going to talk about promises so what do you understand about the difference between promises and observables for promises it's a single event that handles the asynchronous operation which is like either completed or free uh wherever if you consider like promises can be used for basically asynchronous api calls or let's say any asynchronous operations we are doing for observable it is kind of uh what we say subscriber provide subscribers so that let's say you have uh some sort of code that is being executed and you want uh other functions to be subscribed to it whenever that is being executed so uh whenever a particular value or particular event happens observable in informs that particular function uh subscribe functions so that they can know that particular event or particular value has been triggered so that the next operations can be made whereas like in promises you will have like the ban catch and final blocks which are executed based upon the promise state whereas finally will be executed in all the state if like promises rejected or resolved nice you you did the homework right so you are quite good javascript man so thanks for your rich answer so uh let's keep on promises okay uh what do you understand about the difference in this this kind of question uh you face it in all javascript interview okay uh what do you understand by the difference between prompts. all and prompts dot all settled okay so promise. all uh let's say you have a number of promises ongoing and like as soon as one of the promises gets rejected promise always promise that all will just reject from there on it won't like uh take forward and if you have promise dot all settled that will never reject it will resolve all the promises so let's say if you have number of promises in that you will still have the state of that particular promise and whatever the value uh that promise has returned so let's say if it is rejected or resolved you will have state and you will still have the whatever error value or result value that particular function has returned correct so uh if you have a prompts.